渲染zh-Hans

迄

Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.

Creates an exclusive range with a Latin keyword.

Syntax: <expression> 迄 <expression>

Category#

range

Examples#

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

Creates an exclusive range with a Latin keyword.

# =============================================================================
# 迄 — Creates an exclusive range with a Latin keyword.
# =============================================================================
#
# What this teaches:
#   • Exclusive range iteration — `范围 <initium> 迄 <finis>` iterates from
#     initium up to (but not including) finis
#   • Range keyword pattern — `迄` provides a natural-language alternative
#     to symbolic range syntax
#
# Common mistakes:
#   • confusing `迄` (exclusive upper bound) with `到` (inclusive) — `0 迄 4` yields 0,1,2,3 while `0 到 4` yields 0,1,2,3,4
#
# See also: 到, ‥
# =============================================================================

# 迄 — exclusive upper bound for range iteration
#
# 遍历 范围 <initium> 迄 <finis> <var> { … }
#
# GRAMMAR:
#   iterStmt :← '遍历' '范围' expr '迄' expr binding '{' stmt* '}'
#
# EXPECTED OUTPUT:
#   none

main {
    # i = 0, 1, 2, 3 (stops before 4)
    for range 0 before 4 const i {
        print i
    }
}

Expected output:

0
1
2
3