Kết xuấtvi

unarius

Translation status: Tiếng Việt reader-locale proof. Term names and code fences follow the vi pack; supporting prose may still be English.

Unary negation, logical not, sign comparisons, and optional presence tests.

Syntax: -<expr> | không <expr> | <expr> > 0 | <expr> là rỗng_ty

Category#

operators

Examples#

radix/corpus/unarius/unarius.fab (canonical · operator-group)#

Unary negation, logical not, sign comparisons, and optional presence tests.

# =============================================================================
# unarius — Unary negation, logical not, sign comparisons, and optional presence tests.
# =============================================================================
#
# What this teaches:
#   • Unary operators — negation (`-`), logical not (`không`), and sign comparisons
#   • Null checks — `est rỗng_ty` and `không est rỗng_ty` for optional presence testing
#
# Common mistakes:
#   • confusing không (logical not, prefix) with - (numeric negation) or ¬ (the Unicode not sign)
#
# See also: không, est, không est
# =============================================================================




# unarius — negation, logical not, sign comparisons, and optional presence
#
# -<expr>  không <logic>  <expr> > 0  <expr> < 0
# <expr> est rỗng_ty   <expr> không est rỗng_ty
#
# GRAMMAR:
#   unaryExpr :← ('-' | 'không') expr
#
# EXPECTED OUTPUT:
#   unarius.expected — unary operator samples.

main {
    # Numeric negation
    const int x ← 5
    const int neg ← -x
    # -5
    print neg

    # Logical negation
    const bool flag ← true
    const bool non_signum ← not flag
    # sai
    print non_signum

    # Positive/negative checks
    const int a ← 10
    const int b ← -3
    # đúng
    print a ≻ 0
    # sai
    print a ≺ 0
    # sai
    print b ≻ 0
    # đúng
    print b ≺ 0

    # Null checks
    const string ∪ none forsitan ← null
    # đúng
    print forsitan is none
    # sai
    print forsitan not is none
    const string ∪ none adest ← "salve"
    # sai
    print adest is none
    # đúng
    print adest not is none
}

Expected output:

-5
falsum
verum
falsum
falsum
verum
verum
falsum
falsum
verum