Sorting algorithms/Gnome sort: Difference between revisions

fix cut&paste error
(J - first draft)
(fix cut&paste error)
Line 205:
</lang>
 
Note 1: this implementation of swap is actually rather silly, and will not work on long lists. A better implementation would be: <lang J>swap=: position (] {~ _1 0 + [)`(0 _1 + [)`]}^:(*@[) ]</lang>
 
Note 2: this implementation only works for domains where > is defined (in J, "greater than" only works on numbers). To work around this issue, you could define: <lang J>gt=: -.@(-: /:~)@,&<
Anonymous user