range
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Selects numeric range iteration in an for loop.
Syntax: for range <range> <binding>
Category#
iteration
Related#
Examples#
radix/corpus/ab/ab.fab (canonical · keyword)#
Selects numeric range iteration in an for loop.
# =============================================================================
# range — Selects numeric range iteration in an for loop.
# =============================================================================
#
# What this teaches:
# • `for range` bounded range iteration — iterates over a numeric range with
# an optional step
# • Step syntax — the `per <step>` clause controls stride within the range
#
# Common mistakes:
# • using the retired `range`/`ubi` collection pipeline DSL; use ordinary collection methods and closures instead
#
# See also: for, from, ref, per, range pipeline
# =============================================================================
# range — bounded iteration step
#
# GRAMMAR:
# iteraStmt :← 'for' 'range' expr '‥' expr step? 'const' ident block
#
# EXPECTED OUTPUT:
# Scalar stdout smoke (see body).
#
main {
for range 0‥10 step 2 const i {
print i
}
}Expected output:
0
2
4
6
8