[Haskell-cafe] Newbie question

Pieter Laeremans pieter at laeremans.org
Fri Dec 29 21:33:23 EST 2006


Hi,

I'm reading the Haskell school of expression by Paul Hudok. Great book.

However I would like some feedback about a solution to an exercise

The problem is quite simple :

define f1 and f2 (using higher order functions ) such that

f1 (f2 (*) [1..4]) 5 => [5,10,15,20]

I have come up with the following solution :

f2 :: (a->b)->[a] -> [b]
f2 f xs = map f xs
f1 fs a = map (applyOp a) fs
applyOp  b f = f b


But I guess there must be some more elegant way. f2 isn't at all  
original.
And the applyOp sounds silly.

Any comments or suggestions are welcome.

thanks,

Pieter


More information about the Haskell-Cafe mailing list