Skip to content

Instantly share code, notes, and snippets.

@yonta
Last active July 30, 2019 16:11
Show Gist options
  • Save yonta/63f5eacf7b596b41c5f44abcdae8394c to your computer and use it in GitHub Desktop.
Save yonta/63f5eacf7b596b41c5f44abcdae8394c to your computer and use it in GitHub Desktop.
粛清だ
fun stalinSort nil = nil
| stalinSort (h::t) =
let
fun sort _ nil = nil
| sort x (h::t) =
if x < h then h :: sort h t
else sort x t
in
h :: sort h t
end
fun stalinSort2 nil = nil
| stalinSort2 (l as [_]) = l
| stalinSort2 (t1 :: (h1 as (t2 :: h2))¡=
if t1 < t2 then t1 :: stalinSort2 h1
else stalinSort2 (t1 :: h2)
fun neoStalinSort _ = nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment