Skip to content

Currying

Bill Hails edited this page Jun 8, 2024 · 5 revisions

Functions can be curried, For example:

let
    link "listutils.fn" as list;

    fn mul(x, y) {
        x * y
    }
in
    list.map(mul(2), [1, 2, 3, 4]); // [2, 4, 6, 8]

Note that mul is defined with two arguments but called with only one, resulting an a closure that accepts the second argument and performs the computation.

Next: Pattern Matching

Clone this wiki locally