Add examples

This commit is contained in:
2020-04-25 15:04:09 +02:00
parent 3136a08c63
commit 68cc5e5b51
11 changed files with 836 additions and 0 deletions

21
examples/bubble_sort.mus Executable file
View File

@@ -0,0 +1,21 @@
import smnp.io;
import smnp.collection;
import smnp.math;
function bubbleSort(numbers: list<int, float>) {
sorted = numbers;
-range(0, numbers.size) as i ^ {
i as j ^ {
if (sorted.get(j) > sorted.get(j+1)) {
sorted = sorted.swap(j, j+1);
}
}
}
return sorted;
}
randList = range(1, 20).shuffle();
println(randList);
println(bubbleSort(randList));