Anonymous user
Sorting algorithms/Cocktail sort: Difference between revisions
Updated to work with current version of Nim (1.4).
ReeceGoding (talk | contribs) (→{{header|R}}: Used a cool R trick and tried to follow pseudo-code more closely. Also added more outputs.) |
(Updated to work with current version of Nim (1.4).) |
||
Line 2,630:
=={{header|Nim}}==
<lang nim>template trySwap():
if a[i] < a[i-1]:
swap a[i], a[i-1]
Line 2,640:
while not t:
t = true
for i in 1 ..
if t: break
for i in countdown(l-1, 1): trySwap
|