NLinker icon

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

NLinker | PRO | 10/25/17 11:18:22 AM UTC | 0 ⭐ | 815 👁️ | Never ⏰ | []
Haskell |

1.02 KB

|

None

|

0 👍

/

0 👎

λ> :t uncurry
uncurry :: (a -> b -> c) -> (a, b) -> c
λ> :t ($)
($) :: (a -> b) -> a -> b
λ> :t uncurry ($)
uncurry ($) :: (a -> c, a) -> c
λ> :t map (uncurry ($))
map (uncurry ($)) :: [(a -> b, a)] -> [b]
 
λ> f x y = map (uncurry ($)) (zip x y)
λ> :t f
f :: [a -> b] -> [a] -> [b]
λ> f x y = (map  (uncurry ($)))  (zip x y)
λ> f x y = (map  (uncurry ($)))  ((zip x) y)
λ> f x y = ((map (uncurry ($))) . (zip x)) y
λ> f x   = ((map (uncurry ($))) . (zip x))
λ> f x   = (map (uncurry ($))) . (zip x)
λ> f x   = (.) (map (uncurry ($)))  (zip x)
λ> f x   = ((.) (map (uncurry ($)))) (zip x)
λ> f x   = (((.) (map (uncurry ($)))) . zip) x
λ> f     = (((.) (map (uncurry ($)))) . zip)
λ> f     = ((.) ((map . uncurry) ($))) . zip
λ> :t f
f :: [a -> b] -> [a] -> [b]
λ> f [succ, id, id, succ] [1,2,3,4]
[2,2,3,5]
λ>
 
-- But all this has no sense because
λ> :t id
id :: a -> a
λ> :t zipWith
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
λ> (zipWith id) [succ, id, id, succ] [1,2,3,4]
[2,2,3,5]
λ>

Comments