Last active
August 29, 2015 13:59
-
-
Save keizo042/10568048 to your computer and use it in GitHub Desktop.
zipWith 実装してみようと思ったけど上手くかね。わかんね。
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
--zipTwo :: ( a -> b -> c ) -> [a] -> [b] -> [c] | |
--zipTwo _ [] _ = [] | |
--zipTwo _ _ [] = [] | |
--zipTwo f (x:xs) (y:ys) = f x y : f xs ys | |
--分かった 再帰を使っているのに引数にとった関数を使おうとしているから | |
-- 上手くいかなかった | |
zipTwo :: (a -> b -> c) -> [a] -> [b] -> [c] | |
zipTwo f [] _ = [] | |
zipTwo f _ [] = [] | |
zipTwo f (x:xs) (y:ys) = f x y : zipTwo f xs ys | |
main = print ( zipTwo (+) [1..10] [1..10] ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment