Advertisement
SepandMeenu

map via foldr

Mar 18th, 2018
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- map via foldr
  2. mapFoldR :: (a -> b) -> [a] -> [b]
  3. mapFoldR f xs = foldr (\x y -> (f x):y) [] xs
  4.  
  5. -- tests
  6. test_mapFoldR = (map f xs) == (mapFoldR f xs)
  7.   where f x = x + 1
  8.         xs = [1..10]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement