การเรนเดอร์th-TH

ช่วง

Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.

Selects numeric range iteration in an วน loop.

Syntax: วน ช่วง <range> <binding>

Category#

iteration

Examples#

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

Selects numeric range iteration in an วน loop.

# =============================================================================
# ช่วง — Selects numeric range iteration in an วน loop.
# =============================================================================
#
# What this teaches:
#   • `วน ช่วง` 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 `ช่วง`/`ubi` collection pipeline DSL; use ordinary collection methods and closures instead
#
# See also: วน, ออก, จาก, per, ช่วง pipeline
# =============================================================================

# ช่วง — bounded iteration step
#
# GRAMMAR:
#   iteraStmt :← 'วน' 'ช่วง' expr '‥' expr step? 'คงที่' 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