id, ($), (.) and \ aren’t introduced until later in the text, using concepts only from 9.1 and earlier, one answer would be: applyAll :: [(a -> a)] -> a -> a applyAll = flip (foldr aux) where aux f x = f x
4 responses to “Exercise 9.5”
applyAll fs x = foldr id x fs
applyAll fs x = foldr ($) x fs
applyAll = foldr (.) id
id, ($), (.) and \ aren’t introduced until later in the text, using concepts only from 9.1 and earlier, one answer would be:
applyAll :: [(a -> a)] -> a -> a
applyAll = flip (foldr aux)
where aux f x = f x