5. What’s wrong with imperative
code?
• It is repetitive
• It is lengthy
• (higher chances to introduce bugs)
• (harder to read)
• It describes what to do and how
• (mixing low-level and high-level concepts)
15. Pure vs side-effects
• Pure functions:
– Maht.Sin(X)
– String.Length
– List<T>.IndexOf(T)
• Functions with side effects:
– List<T>.Add(T)
– DateTime.UtcNow
– Console.WriteLine()
42. Currying
Transform
f: (X * Y) -> Z Haskell Curry
into
f: X -> (Y -> Z)
Input: Function with N parameters
Output: chain of N functions with 1
parameter each
47. Main ideas
• Functions as first class citizens
• Compose complex functions from simple
• Create specific functions out of generic ones
• More generic and reusable code with higher
order functions
• For less code and less bugs