In an exam past paper I found online it asks us to rewrite the following higher order functions using list comprehension:
hofOne = map (*2) [1,2,3]
hofTwo = filter isSquare randomList
I'm not sure if I'm misunderstanding higher order functions, because I recognize that both the map
and filter
functions themselves are higher order functions, but I don't understand how that makes the hofOne
and hofTwo
functions higher order when neither of them take a function as a parameter, nor return a function as a result.
Is there something I'm missing?
(Num a) => [a]
, while the second depends on the exact types ofisSquare
andrandomList
, but will definitely be of some type[a]
with some possible restrictions ona
. No->
arrows, so they're not functions. (And a higher-order function which takes a function as a parameter will have a bracketed part with one or more arrows in.) – Robin Zigmond