渲染zh-Hant

scalaria

Translation status: 繁體中文 reader-locale proof. Code fences render through the zh-Hant pipeline; prose is canonical Latin.

Scalar operations on numerus, fractus, and bivalens in function signatures.

Syntax: functio <name>(<scalar-params>) → <scalar-type> <block>

Category#

type

Examples#

radix/corpus/scalaria/scalaria.fab (canonical · concept)#

Scalar operations on numerus, fractus, and bivalens in function signatures.

# =============================================================================
# scalaria — Scalar operations on numerus, fractus, and bivalens in function
# signatures.
# =============================================================================
#
# What this teaches:
#   • Primitive type operations — demonstrates `numerus` arithmetic, `fractus`
#     division, `bivalens` comparison and boolean logic in function signatures
#   • Function composition — shows how scalar types compose through parameters
#     and return types
#
# Common mistakes:
#   • Mixing `numerus` and `fractus` without explicit `↦` conversion — primitive families have distinct type widths (SEM008).
#
# See also: numerus, fractus, bivalens
# =============================================================================



# scalaria — scalar operations on primitive types
#
# Demonstrates numerus, fractus, and bivalens parameters with arithmetic,
# comparison, and boolean logic in function signatures.
#
# GRAMMAR:
#   funcDecl :← 'functio' ident '(' paramList ')' ('→' type)? block
#
# EXPECTED OUTPUT:
#   Compile-only declaration tour (no incipit).

fn numerica(int a, int b)  int {
    return (a + b) * 2
}

fn fracta(float a, float b)  float {
    return (a + b) / 2.0
}

fn comparata(int a, int b)  bool {
    return a  b
}

fn logica(bool a, bool b)  bool {
    return not a and b
}