रेंडरिंगhi

अन्यथायदि

Translation status: हिन्दी reader-locale proof. Term names and code fences follow the hi pack; supporting prose may still be English.

Adds an else-if branch after a previous यदि branch.

Aliases: else if

Syntax: अन्यथायदि <condition> <block>

Category#

control-flow

Examples#

radix/corpus/si/sin.fab (canonical · keyword)#

Adds an else-if branch after a previous यदि branch.

# =============================================================================
# अन्यथायदि — Adds an else-if branch after a previous यदि branch.
# =============================================================================
#
# What this teaches:
#   • Else-if chains — `अन्यथायदि <condition> { body }` adds intermediate conditional
#     branches between `यदि` and `अन्यथा`
#   • First match wins: evaluation stops at the first `यदि` or `अन्यथायदि` whose
#     condition is `सत्य`
#
# Common mistakes:
#   • TODO: forgetting that `अन्यथायदि` blocks are skipped once a preceding branch
#     matches
#
# See also: यदि, अन्यथा
# =============================================================================

# si-sin-secus (poetic if-else-if chain)
#
# यदि <cond> { }
# अन्यथायदि <cond> { }
# अन्यथा { }
#
# GRAMMAR:
#   ifStmt :← 'यदि' expr block ('अन्यथायदि' expr block)* ('अन्यथा' block)?
#
# EXPECTED OUTPUT:
#   Afternoon (hour=14 matches first अन्यथायदि branch).

main {
    const int hour ← 14
    if hour ≺ 6 {
        print "Late night"
    }
    elif hour ≺ 12 {
        print "Morning"
    }
    elif hour ≺ 18 {
        # 14 ≥ 12 and 14 < 18
        print "Afternoon"
    }
    elif hour ≺ 22 {
        print "Evening"
    }
    else {
        print "Night"
    }
}

Expected output:

Afternoon

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

Adds an else-if branch after a previous यदि branch.

# =============================================================================
# अन्यथायदि — Adds an else-if branch after a previous यदि branch.
# =============================================================================
#
# What this teaches:
#   • Standalone else-if — `अन्यथायदि` provides an intermediate conditional branch
#     evaluated only when the preceding `यदि` condition was `असत्य`
#   • Chains: `यदि { } अन्यथायदि { } अन्यथा { }` for multi-way branching
#
# Common mistakes:
#   • Writing `अन्यथा यदि` instead of the canonical `अन्यथायदि` for else-if branches.
#
# See also: यदि, अन्यथा
# =============================================================================

# अन्यथायदि — else-if branch
#
# GRAMMAR:
#   elseIfClause :← 'अन्यथायदि' expr block
#
# EXPECTED OUTPUT:
#   Scalar stdout smoke (see body).
#
# BACKEND:
#   Cross-ref: यदि/sin.fab.
#

main {
    const int score ← 85
    if score ≥ 90 {
        print "excellent"
    }
    elif score ≥ 80 {
        print "good"
    }
    else {
        print "needs work"
    }
}

Expected output:

good