Chapter 9: More about Higher Order Functions (part 1)

Comments

You could fix the applyAll problem by reversing the function list before it's used:

Goodness, it stripped out my haskell. Here was my suggestion:

applyAll = (flip $ foldr ($)) . reverse

This way you get to avoid all of the problems arising foldl and ($).
Or you could write:

applyAll = flip $ foldl (flip ($))

which does the same thing but dosn't need to reverse the list first.

(You should be able to figure out the reason for this by comparing the types of foldl and fodlr :) )
Oh, cool, that makes sense, thanks for pointing it out!
This doesn't immediately make sense, I'll take your advice and compare the types when I get chance, thanks!

Post a comment

Already a Vox member? Sign in