NLinker

Point-free version of f :: [a -> b] -> [a] -> [b]

Oct 25th, 2017
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. λ> :t uncurry
  2. uncurry :: (a -> b -> c) -> (a, b) -> c
  3. λ> :t ($)
  4. ($) :: (a -> b) -> a -> b
  5. λ> :t uncurry ($)
  6. uncurry ($) :: (a -> c, a) -> c
  7. λ> :t map (uncurry ($))
  8. map (uncurry ($)) :: [(a -> b, a)] -> [b]
  9.  
  10. λ> f x y = map (uncurry ($)) (zip x y)
  11. λ> :t f
  12. f :: [a -> b] -> [a] -> [b]
  13. λ> f x y = (map  (uncurry ($)))  (zip x y)
  14. λ> f x y = (map  (uncurry ($)))  ((zip x) y)
  15. λ> f x y = ((map (uncurry ($))) . (zip x)) y
  16. λ> f x   = ((map (uncurry ($))) . (zip x))
  17. λ> f x   = (map (uncurry ($))) . (zip x)
  18. λ> f x   = (.) (map (uncurry ($)))  (zip x)
  19. λ> f x   = ((.) (map (uncurry ($)))) (zip x)
  20. λ> f x   = (((.) (map (uncurry ($)))) . zip) x
  21. λ> f     = (((.) (map (uncurry ($)))) . zip)
  22. λ> f     = ((.) ((map . uncurry) ($))) . zip
  23. λ> :t f
  24. f :: [a -> b] -> [a] -> [b]
  25. λ> f [succ, id, id, succ] [1,2,3,4]
  26. [2,2,3,5]
  27. λ>
  28.  
  29. -- But all this has no sense because
  30. λ> :t id
  31. id :: a -> a
  32. λ> :t zipWith
  33. zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
  34. λ> (zipWith id) [succ, id, id, succ] [1,2,3,4]
  35. [2,2,3,5]
  36. λ>
Add Comment
Please, Sign In to add comment