العرضar

باقي

Translation status: العربية reader-locale proof. Term names and code fences follow the ar pack; supporting prose may still be English.

Collects remaining parameters, operands, or extracted fields.

Aliases: rest

Syntax: باقي <type> <name>

Category#

function

Examples#

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

Collects remaining parameters, operands, or extracted fields.

# =============================================================================
# باقي — Collects remaining parameters, operands, or extracted fields.
# =============================================================================
#
# What this teaches:
#   • Rest parameters — `باقي <type> <name>` in a function signature collects
#     all remaining arguments into a list
#   • Variadic functions — `باقي قائمة<عدد> numeri` enables summing an
#     arbitrary number of numeric arguments
#
# Common mistakes:
#   • confusing `باقي` (rest parameter collecting remaining args into a list) with `فارغ` (an empty collection initializer)
#
# See also: دالة, معامل, من
# =============================================================================

# باقي — rest parameter (collects remaining arguments)
#
# دالة <اسم>(باقي <نمط> <اسم>) → <نمط>
#
# GRAMMAR:
#   param :← 'باقي' type ident
#
# EXPECTED OUTPUT:
#   none

fn المجموع(rest list<int> numeri) → int {
    var _ total ← 0

    for from numeri const n {
        total ← total + n
    }

    return total
}

main {
    # باقي receives the whole قائمة
    print المجموع([1, 2, 3, 4])
}

Expected output:

10