Starts a for-each iteration statement.
Aliases: iterate
Syntax: itera <mode> <expression> <binding> <block>
Category
control-flow
Related
Examples
examples/corpus/itera/cursor-iteratio.fab (canonical · keyword)
Starts a for-each iteration statement.
# itera ex — cursor function return iteration
#
# itera ex <cursor-call> fixum <item> { <body> }
#
# GRAMMAR:
# forInStmt :← 'itera' 'ex' callExpr 'fixum' ident block
# cursorDecl :← '@' 'cursor' funcDecl
#
# EXPECTED OUTPUT:
# Sync cursor values and collected lista of doubled results.
#
# BACKEND:
# Go backend emits cursor generators as eager slices for e2e parity.
# Multi-value sync function that yields values via cede
@ cursor
functio grena(numerus n) → numerus {
itera ab 0‥n fixum i {
cede i
}
}
# Multi-value futura function that yields values via cede
@ futura
@ cursor
functio grena_futurum(numerus n) → numerus {
itera ab 0‥n fixum i {
cede i
}
}
incipit {
# Direct consumption of cursor yield stream
nota "Sync cursor iteration:"
itera ex grena(3) fixum num {
nota " numerus: §"(num)
}
# Collect all results from cursor function
varia _ effecta ← []
itera ex grena(5) fixum num {
effecta.appende(num * 2)
}
nota "Sync collected:"
nota effecta
# Note: Futura iteration would require futura context
# itera ex grena_futurum(3) fixum num {
# nota num
# }
}Expected output:
Sync cursor iteration:
numerus: 0
numerus: 1
numerus: 2
Sync collected:
[0, 2, 4, 6, 8]
examples/corpus/itera/in-functione.fab (canonical · keyword)
Starts a for-each iteration statement.
# itera ex — accumulator pattern inside functio
#
# itera ex <lista> fixum <item> { <body> }
#
# GRAMMAR:
# forInStmt :← 'itera' 'ex' expr 'fixum' ident block
#
# EXPECTED OUTPUT:
# Sums, maxima, and counts above a threshold for sample listas.
functio summa(lista<numerus> numeri) → numerus {
varia numerus total ← 0
itera ex numeri fixum n {
total ← total + n
}
redde total
}
# Assumes non-empty lista (seed from first element)
functio maximum(lista<numerus> numeri) → numerus {
varia numerus max ← numeri[0]
itera ex numeri fixum n {
si n > max {
max ← n
}
}
redde max
}
functio supra(lista<numerus> numeri, numerus limen) → numerus {
varia numerus numerus ← 0
itera ex numeri fixum n {
si n > limen {
numerus ← numerus + 1
}
}
redde numerus
}
incipit {
fixum _ numeri ← [1, 2, 3, 4, 5]
nota summa(numeri)
nota maximum(numeri)
nota supra(numeri, 3)
nota summa([10, 20, 30])
nota maximum([5, 12, 8, 20, 3])
}Expected output:
15
5
2
60
20
examples/corpus/itera/intervallum-gradus.fab (canonical · keyword)
Starts a for-each iteration statement.
# itera ab — ranges with step using per
#
# itera ab <start>‥<end> per <step> fixum <item> { <body> }
# itera ab <start>…<end> per <step> fixum <item> { <body> }
#
# GRAMMAR:
# forRangeStmt :← 'itera' 'ab' rangeExpr 'per' expr ('fixum' | 'varia') ident block
#
# EXPECTED OUTPUT:
# none — stdout not pinned for this exemplum.
incipit {
# Step by 2 (exclusive: 0, 2, 4, 6, 8)
itera ab 0‥10 per 2 fixum i {
nota i
}
# Step by 2 (inclusive: 0, 2, 4, 6, 8, 10)
itera ab 0…10 per 2 fixum i {
nota i
}
# Step by 3
itera ab 0‥15 per 3 fixum i {
nota i
}
# Descending with negative step
itera ab 10‥0 per -1 fixum i {
nota i
}
# Descending by 2
itera ab 10‥0 per -2 fixum i {
nota i
}
}examples/corpus/itera/intervallum.fab (canonical · keyword)
Starts a for-each iteration statement.
# itera ab — range expressions with exclusive and inclusive bounds
#
# itera ab <start>‥<end> fixum <item> { <body> } — exclusive end
# itera ab <start> ante <end> fixum <item> { <body> } — explicit exclusive
# itera ab <start>…<end> fixum <item> { <body> } — inclusive end
#
# GRAMMAR:
# forRangeStmt :← 'itera' 'ab' rangeExpr ('fixum' | 'varia') ident block
#
# EXPECTED OUTPUT:
# none — stdout not pinned for this exemplum.
incipit {
# Basic range (exclusive: 0, 1, 2, 3, 4)
itera ab 0‥5 fixum i {
nota i
}
# Explicit exclusive with ante (same as ‥)
itera ab 0 ante 5 fixum i {
nota i
}
# Inclusive range with … (0, 1, 2, 3, 4, 5)
itera ab 0…5 fixum i {
nota i
}
# Range starting from non-zero
itera ab 5‥10 fixum i {
nota i
}
# Descending direction
itera ab 5‥0 fixum i {
nota i
}
}examples/corpus/itera/nidificatus.fab (canonical · keyword)
Starts a for-each iteration statement.
# itera ex — nested loops (Cartesian product)
#
# itera ex <collection> fixum <item> { <body> }
# itera ab <start>‥<end> fixum <item> { <body> }
#
# GRAMMAR:
# forInStmt :← 'itera' 'ex' expr 'fixum' ident block
# forRangeStmt :← 'itera' 'ab' rangeExpr 'fixum' ident block
#
# EXPECTED OUTPUT:
# none — row/col pairs, multiplication table, coordinate grids.
#
# BACKEND:
# Go backend does not emit nested itera yet — compile-only smoke.
incipit {
# Nested lista iteration — 3 × 3 combinations
fixum _ rows ← [1, 2, 3]
fixum _ cols ← ["A", "B", "C"]
itera ex rows fixum row {
itera ex cols fixum col {
nota row, col
}
}
# Multiplication table over exclusive ranges 1‥4 (i, j ∈ {1,2,3})
itera ab 1‥4 fixum i {
itera ab 1‥4 fixum j {
nota i, "*", j, "←", i * j
}
}
# Nested ranges: 4 × 4 grid of (x, y) with x, y ∈ {0,1,2,3}
itera ab 0‥3 fixum x {
itera ab 0‥3 fixum y {
nota x, y
}
}
}Expected output:
1 A
1 B
1 C
2 A
2 B
2 C
3 A
3 B
3 C
1 * 1 ← 1
1 * 2 ← 2
1 * 3 ← 3
2 * 1 ← 2
2 * 2 ← 4
2 * 3 ← 6
3 * 1 ← 3
3 * 2 ← 6
3 * 3 ← 9
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2