Skip to content

Instantly share code, notes, and snippets.

@vito
Created November 13, 2010 19:45
Show Gist options
  • Save vito/675578 to your computer and use it in GitHub Desktop.
Save vito/675578 to your computer and use it in GitHub Desktop.
atomo insertion-sort
~ $ atomo
[0]> (y . ys) insert: x by: pred := if: (pred call: [x, y]) then: { x . y . ys } else: { y . (ys insert: x by: pred) }
@ok
[1]> [] insert: x by: _ := [x]
@ok
[2]> [] insertion-sort: _ := []
@ok
[3]> (x . xs) insertion-sort: pred := (xs insertion-sort: pred) insert: x by: pred
@ok
[4]> [5, 3, 10] insertion-sort: @<=
[3, 5, 10]
[5]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment