all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,10 @@
|
|||
s@(Sequence traits) cocktailSort
|
||||
[ |swapped|
|
||||
swapped: False.
|
||||
s size <= 1 ifTrue: [^ s].
|
||||
[{0 to: s size - 2. s size - 2 downTo: 0}
|
||||
do: [|:range| range do: [|:index| (s at: index) > (s at: index + 1) ifTrue: [s swap: index with: index + 1. swapped: True]].
|
||||
swapped ifFalse: [^ s].
|
||||
swapped: False].
|
||||
] loop
|
||||
].
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
slate[1]> #( 10 9 8 7 6 0 -5) cocktailSort.
|
||||
{-5. 0. 6. 7. 8. 9. 10}
|
||||
Loading…
Add table
Add a link
Reference in a new issue