Chapter 3Elementary Discrete Mathslides.en.pdf:167-170
Currying & Notations
f(a,b) → f(a)(b); prefix, postfix, infix
Def 4.3 — CurryingDef 4.8 — λ-notationDef 4.6 — Fixity
Concept
Currying transforms an -ary function into a chain of unary functions.
Instead of , you write — apply one argument at a time.
Why? Each partial application can be stored, reused, or passed around.
Adding 3 to a number is a function that waits for the second argument.
λ-notation: is the function .
In SML: fn x => E.
Fixity / notation styles:
- Prefix: — function before arguments
- Postfix: — function after argument
- Infix: — function between arguments (used for binary ops)
- Circumfix: — function wraps argument
Animation — currying
Transcript — click a line to jump8 cues
- 0.0sCurrying: Cartesian to Cascaded
- 1.3sCartesian form on the left: (x, y) maps to x + y
- 2.6sCascaded form on the right: x maps to y maps to x + y
- 5.6sThe comma flashes amber in the Cartesian form
- 6.2sThe single arrow flashes amber
- 6.8sBoth arrows flash amber in the cascaded form
- 7.9sA double-headed arrow says the two forms are equivalent
- 9.1sTwo equivalent ways to write a 2-argument function
Practice — score 100% to advance
Multiple choice
Q1
What is currying?
Q2
In , what is ?
Q3
In SML, what is the expression
fn x => x + 1?Q4
Which notation is infix?
Q5
In SML, what is
add 3 (where add takes two args)?Loading…