BubbleLang/Algorithm
Jump to navigation
Jump to search
Swap two numbers
function swap(x: int*, y: int*): var t: int* = x x = y y = t
Thus makes these things:
Bubble sort
function swap(x: int*, y: int*): var t: int* = x x = y y = t function bubble_sort(array: list, x: int): for i in range(0, x): if array[i] > array[i + 1]: swap(array[i], array[i + 1])
Max function using swap
function swap(x: int*, y: int*): var t: int* = x x = y y = t delete max function max(x: int, y: int): if y > x: swap(x, y) return x
Print random character
When you try to char-ize the integer, you'll get the character that has ASCII of that integer.
from random import randint var ascii = randint(0, 1114111) print(char(ascii))