Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created February 4, 2015 11:46
Show Gist options
  • Save shigemk2/9693914a6f66b7baae8e to your computer and use it in GitHub Desktop.
Save shigemk2/9693914a6f66b7baae8e to your computer and use it in GitHub Desktop.
-- map' :: (a -> b) -> [a] -> [b]
-- map' f xs = foldr (\x acc -> f x : acc) [] xs
map' :: (a -> b) -> [a] -> [b]
map' f xs = foldl (\acc x -> acc ++ [f x]) [] xs
main = do
print $ map' (\x -> x + 3) [4,3,1,2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment