I have a homework on higher order functions in Haskell and I'm having a little trouble getting started.
If I could get some help and explanation on the first question, I'm confident I can finish the rest.
Using higher order functions (
map
,fold
, orfilter
), and if necessary lambda expressions, write functionsf1
andf2
such thatf1 (f2 (*) [1,2,3,4]) 5 ~> [5,10,15,20]
f1 =
f2 =
I'm thinking I have to use a partially applied map
so that [1,2,3,4]
becomes [(*1),(*2),(*3),(*4)]
?
f1 g n = g n
and then write f2 such thatf2 (+) [1..4] 5 == [5,10,15,20]
– Ingof2 = map
sounds like a good idea. – Bergi