ปิดล้อม
Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH 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.
# =============================================================================
# ปิดล้อม — 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 `∴` (ปิดล้อม joint for compact closures) with `ดังนั้น` (single-statement body joint for `ถ้า`, `ขณะ`, `กรณี`) — they are not interchangeable
#
# See also: ∴, ฟังก์ชัน, ทำ, จับ, ให้
# =============================================================================
# ปิดล้อม — 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 ผลรวม ← (int a, int b) → int ∴ a + b
print ผลรวม(2, 3)
}Expected output:
10
5