1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
[c
Sorts the items on the stack in such a way that the smallest item will be popped first.
System test:
target/release/laconic -i scripts/bubbleSort.lac 'K(20 5 60 19 #Hello 8 4 0) X#BubbleSort o#fmt 0 Wk, w+k#- w¶'
]
R(
#BubbleSort
$ #len k,
$ #count 0
W
k,
;
$ v#count k
+ :#count 1
$ #lastEl - v#len 2
W(
> v#lastEl 0
$ #el 0
W(
!> v#el v#lastEl
?
<
vv#el
v+v#el 1
;(
$ #tmp vv#el
$ v#el v+v#el 1
$ +v#el 1 v#tmp
)
€
+ :#el 1
)
- :#lastEl 1
)
F
0
- v#len 1
1
#count
K vv#count
)