Partially Applied Lambda (Expression) — skLambda

Addon: skLambda · Category: Expression · Since: 1.1.0

Syntax

%object% with %objects% bound

Description

Pre-binds the leading arguments of a lambda, returning a smaller-arity lambda that supplies the rest. Binding `5` to a `(a, b)` lambda gives a one-argument lambda that calls the original with `5` as its first argument. The original's captured scope is kept (it performs the real call), and the new lambda's declared parameters are the leftover ones, so `number of parameters` reads correctly.

Examples

set {_add} to lambda (a: number, b: number) -> number: return {_a} + {_b}
set {_add5} to {_add} with 5 bound
send "%call lambda {_add5} with 10%"      # 15

View source