العرضar

Translation status: العربية reader-locale proof. Code fences render through the ar pipeline; prose is canonical Latin.

Half-open and inclusive range endpoints in itera ab and intra.

Syntax: <expression> ‥ <expression> | <expression> … <expression>

Category#

range

Examples#

radix/corpus/operatores/range-glyphs.fab (canonical · operator-group)#

Half-open and inclusive range endpoints in itera ab and intra.

# =============================================================================
# ‥ — Half-open and inclusive range endpoints in itera ab and intra.
# =============================================================================
#
# What this teaches:
#   • Exclusive ranges — `‥` (two dots) creates half-open ranges: start inclusive, end exclusive.
#   • Inclusive ranges — `…` (three dots) creates inclusive ranges: both endpoints included.
#
# Common mistakes:
#   • Confusing ‥ (exclusive range) with … (inclusive range) — off-by-one errors are the most common range bug.
#
# See also: ‥, …, ante, usque, intra
# =============================================================================

# operatores/range-glyphs — ‥ (exclusive) and … (inclusive)
#
# GRAMMAR:
#   rangeExpr :← expr ('‥' | '…') expr
#
# EXPECTED OUTPUT:
#   0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5
#
# BACKEND:
#   Cross-ref itera/intervallum.fab and intra/intra.fab.

main {
    var int exclusivus  0
    for range 05 const _ {
        exclusivus 
    }
    # 5 iterations
    print exclusivus

    var int inclusivus  0
    for range 05 const _ {
        inclusivus 
    }
    # 6 iterations
    print inclusivus
}

Expected output:

5
6