haskell - zipWith-ing List of Integers with List of Functions -
How do I make [integer]
with a [integer - & Gt; Integer - & gt; Integer]
to get the [integer - & gt; Integer]
?
Example:
I tried:
prelude & gt; With desired result of [1,2,3] (3 (*))
with zip:
[(* 1), ( * 2), (* 3)]
But I got an error:
& lt; Interactive>: 25: 9: Could not match the expected type `(A0 - & gt; a0 - & gt; a0) - & gt; B - 0 - & gt; In the first argument of 'zip with' with the actual type '[T]', in the expression '[1, 2, 3]', in the expression: zip [1, 2, 3] (repeat 3 (*)) In the equation for an 'this': it = zip [1, 2, 3] (repeat 3 (*))
edit me right - thanks .
It seems that I can do it with applicants:
prelude control. Epicclic & gt; F f = [(*)]
But, can I do this with the zipWith
?
You were close to an operator for the application, $
, which exactly Useful in such cases.
& gt; : T ZIP ($) [(*), (*), (*)] [1..3] ZIP ($) [(*), (*), (*)] [1..3]: (Number B, NUM B) = & gt; [B -> B]
And if you want [1..3]
first, this zip hash (flip ($))
.
Additionally, your appetite variant is wrong, if this causes:
& gt; F f = [(*), (*), (*)]
Comments
Post a Comment