Skip to content

Instantly share code, notes, and snippets.

@chomado
Last active December 17, 2015 11:19
Show Gist options
  • Save chomado/5601105 to your computer and use it in GitHub Desktop.
Save chomado/5601105 to your computer and use it in GitHub Desktop.
さっき書いたsortのやつ、case of使わないで書きなおしてみました。case ofとかOCamlのmatch withとか使わなくても普通にパターンマッチできるのスゴイですHaskell感動しました
mysort2 :: [Int] -> [Int]
mysort2 [] = []
mysort2 (first : rest) = insert (mysort2 rest) first
where
insert [] n = [n]
insert (first : rest) n
| first < n = first : insert rest n
| otherwise = n : first : rest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment