Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- 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