Skip to content

Instantly share code, notes, and snippets.

@moznion
Created July 29, 2012 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moznion/3198518 to your computer and use it in GitHub Desktop.
Save moznion/3198518 to your computer and use it in GitHub Desktop.
スタートHaskell 2 第2回目演習 偶数と奇数にわける
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