Kết xuấtvi

khoảng

Translation status: Tiếng Việt reader-locale proof. Term names and code fences follow the vi pack; supporting prose may still be English.

Selects numeric range iteration in an lặp loop.

Syntax: lặp khoảng <range> <binding>

Category#

iteration

Examples#

radix/corpus/ab/ab.fab (canonical · keyword)#

Selects numeric range iteration in an lặp loop.

# =============================================================================
# khoảng — Selects numeric range iteration in an lặp loop.
# =============================================================================
#
# What this teaches:
#   • `lặp khoảng` 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 `khoảng`/`ubi` collection pipeline DSL; use ordinary collection methods and closures instead
#
# See also: lặp, từ, ra, per, khoảng pipeline
# =============================================================================

# khoảng — bounded iteration step
#
# GRAMMAR:
#   iteraStmt :← 'lặp' 'khoảng' expr '‥' expr step? 'hằng' 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