渲染zh-Hans

integratio

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

Minimal multi-feature happy path across 函数, 常量, 如果, and 显示.

Syntax: integratio — multi-feature happy path

Category#

integration

Examples#

radix/corpus/integratio/minimum-smoke.fab (canonical · concept)#

Minimal multi-feature happy path across 函数, 常量, 如果, and 显示.

# =============================================================================
# integratio — Minimal multi-feature happy path across 函数, 常量, 如果, and 显示
# =============================================================================
#
# What this teaches:
#   • Minimal multi-feature happy path across 函数, 常量, 如果, and 显示.
#   • Related keywords: 函数, 常量, 如果, 显示
#
# Common mistakes:
#   • Writing code outside `入口` that produces side effects — top-level code runs at module load; prefer `入口` for program entry.
#
# See also: 函数, 常量, 如果, 显示
# =============================================================================

# integratio — minimal multi-feature happy path
#
# 函数 name(params) → type { … }
# 常量 _ n ← expr
# 如果 <cond> { … }
# 显示 template with § interpolation
#
# GRAMMAR:
#   funcDecl   :← '函数' ident '(' params ')' ('→' type)? block
#   condStmt   :← '如果' expr block
#   outputStmt :← '显示' expr
#
# EXPECTED OUTPUT:
#   minimum-smoke.expected — par 42 when n is even.

fn par(int n) → bool {
    return n % 2 ≡ 0
}

main {
    const int n ← 42
    if par(n) {
        print "par §"(n)
    }
}

Expected output:

par 42