Created
July 29, 2012 12:49
-
-
Save moznion/3198518 to your computer and use it in GitHub Desktop.
スタートHaskell 2 第2回目演習 偶数と奇数にわける
This file contains hidden or 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
oddEven :: [Int] -> ([Int], [Int]) | |
oddEven [] = ([], []) | |
oddEven (x:xs) | |
| odd x = connectTuple ([x], []) $ oddEven xs | |
| otherwise = connectTuple ([], [x]) $ oddEven xs | |
where | |
connectTuple :: ([a], [b]) -> ([a], [b]) -> ([a], [b]) | |
connectTuple (x1, y1) (x2, y2) = (x1 ++ x2, y1 ++ y2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment