Kết xuấtvi

còn_lại

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

Collects remaining parameters, operands, or extracted fields.

Aliases: rest

Syntax: còn_lại <type> <name>

Category#

function

Examples#

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

Collects remaining parameters, operands, or extracted fields.

# =============================================================================
# còn_lại — Collects remaining parameters, operands, or extracted fields.
# =============================================================================
#
# What this teaches:
#   • Rest parameters — `còn_lại <type> <name>` in a function signature collects
#     all remaining arguments into a list
#   • Variadic functions — `còn_lại danh_sách<số> numeri` enables summing an
#     arbitrary number of numeric arguments
#
# Common mistakes:
#   • confusing `còn_lại` (rest parameter collecting remaining args into a list) with `tập_rỗng` (an empty collection initializer)
#
# See also: hàm, toán_hạng, từ
# =============================================================================

# còn_lại — rest parameter (collects remaining arguments)
#
# hàm <tên>(còn_lại <kiểu_tên> <tên>) → <kiểu_tên>
#
# GRAMMAR:
#   param :← 'còn_lại' type ident
#
# EXPECTED OUTPUT:
#   none

fn tổng(rest list<int> numeri) → int {
    var _ total ← 0

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

    return total
}

main {
    # còn_lại receives the whole danh_sách
    print tổng([1, 2, 3, 4])
}

Expected output:

10