Something went wrong. Try again.
An experiment in static, refcounted, procedural language with ownership
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839fn main() unit = { let mut slice = [1, 3, 42, 487, 5, 66, 4055, 33] print("Before: ") slice.print() bubble-sort(&mut slice) print("After: ") slice.print()}fn bubble-sort(slice: &mut []int) unit = { let mut n = slice.len let mut swapped = true for if swapped { swapped = false let mut i = 1 for if i < n { if slice.[i - 1] > slice.[i] { slice.swap(i - 1, i) swapped = true } i += 1 } n -= 1 }}fn print(slice: &[]int) unit = { let mut i = 0 for if i < slice.len { print("{slice.[i]} ") i += 1 } println()}