08.08.07

Exercise 9.5

Posted in Uncategorized at 10:35 pm by admin

applyAll :: [(a -> a)] -> a -> a
applyAll [] x = x
applyAll (f:fs) x = f (applyAll fs x)

4 Comments »

  1. anonyoumous said,

    February 21, 2008 at 12:48 pm

    applyAll fs x = foldr id x fs

  2. anonymous said,

    June 10, 2008 at 11:15 pm

    applyAll fs x = foldr ($) x fs

  3. Kazu Yamamoto said,

    February 6, 2009 at 12:19 am

    applyAll = foldr (.) id

  4. RJP said,

    June 22, 2014 at 8:45 am

    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

Leave a Comment