Haskell Higher Order Functions

  • filter (function) list
  • 
                ghci> filter (>6) [1,2,3,4,5,6,7,8,9]      
                [7,8,9]
                
  • map (function) list
  • 
                ghci> map (+2) [1,2,3,4,5,6,7,8,9]
                [3,4,5,6,7,8,9,10.11]
                
  • foldl/foldr (function) start_value list
  • 
                ghci> foldl (-) 100 [3,4,5] -- fold from the left
                88  -- is ((100 - 3) - 4) - 5
                ghc > foldr (-) 100 [3,4,5] -- fold from the right         
                -96 -- is 3 - (4 - (5 - 100))