Skip to content

Instantly share code, notes, and snippets.

@chomado
Created June 17, 2013 10:29
Show Gist options
  • Save chomado/5796029 to your computer and use it in GitHub Desktop.
Save chomado/5796029 to your computer and use it in GitHub Desktop.
halve :: [a] -> ([a], [a])
halve xs = splitAt n xs
where n = length xs `div` 2
-- 実行例
--halve [1, 2, 3, 4, 5, 6]
--([1, 2, 3], [4, 5, 6])
-- drop n xs ... リストからn個の要素を取り除く
-- splitAt n xs = (take n xs, drop n xs) ... リストをn番目の要素のところで分割する
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment