Haskell Anonymous & Currying

  • Anonymous Functions
  • 
                (\x -> x + 3)
                (\x -> (\y -> y + x))
                
  • Currying
  • 
                foo 3 5 7             -- is really ((foo 3) 5 ) 7         
                foo a b c = a + b - c 
                  -- foo is (\a -> (\b -> (\c -> a + b - c)))
                
                foo 3 5 7
                  --    (\a -> (\b - > (\c -> a + b - c ))) 3 5 7
                  -- => (\b -> (\c -> 3 + b - c)) 5 7
                  -- => (\c -> 3 + 5 - c) 7
                  -- => 3 + 5 - 7
                  -- => 8 - 7
                  -- => 1
    
                funa.funb 2 -- is funa (funb 2)