Currying
inc x = x+1
inc 1
inc 2
inc 3
-- input of a function and a parameter
map inc [1..10]
add (x,y) = x+y
add (2,3) = 5
Curried function
Takes inputs just like add, but takes arguments one at a time rather than in a pair
addCurry x y = x+y
addCurry 1 2 = 3
Purpose
- Don't need to give all inputs when calling, so you can partially apply it
- add won't work with only one input, but addCurry will
Think of it like a cash machine
- Cash machine needs your debit card
- then your pin
- then your amount of money as a request
-- Always gives £ 100
cm card pin request = 100
-- also defined with lambda expressions
cm = \card -> (\pin -> (\request -> 100))