Created
June 17, 2013 10:29
-
-
Save chomado/5796029 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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