lambda
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Declares or explains an inline closure expression; compact ∴ syntax is preferred for new code.
Syntax: <type> <name> [→ <type>] [⇥ <error-type>] ∴ <expression|fac-block>
Category#
function
Related#
Examples#
radix/corpus/clausura/clausura.fab (canonical · keyword)#
Declares or explains an inline closure expression; compact ∴ syntax is preferred for new code.
# =============================================================================
# lambda — Declares or explains an inline closure expression; compact ∴
# syntax is preferred for new code.
# =============================================================================
#
# What this teaches:
# • Closure basics — `∴` (therefore) introduces a closure body after the
# parameter list
# • Compact syntax — the `∴` form is preferred over block-delimited closures
# for simple expressions
#
# Common mistakes:
# • confusing `∴` (lambda joint for compact closures) with `then` (single-statement body joint for `if`, `while`, `case`) — they are not interchangeable
#
# See also: ∴, fn, do, catch, yield
# =============================================================================
# lambda — closure bodies with ∴ and ⇥
#
# GRAMMAR:
# closureExpr :← paramList '∴' expr
#
# EXPECTED OUTPUT:
# Scalar stdout smoke (see body).
#
# BACKEND:
# Cross-ref: clausa/clausa.fab.
#
main {
const (int) → int dupla ← int x ∴ x * 2
print dupla(5)
const (int, int) → int sum ← (int a, int b) → int ∴ a + b
print sum(2, 3)
}Expected output:
10
5