รายการ
Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.
Generic ordered collection type.
Aliases: array, list
Syntax: รายการ<T>
Category#
collection
Related#
Examples#
radix/corpus/lista/lista.fab (canonical · keyword)#
Generic ordered collection type.
# =============================================================================
# รายการ — Generic ordered collection type.
# =============================================================================
#
# What this teaches:
# • รายการ literal syntax — `[elem, ...]` with typed empty collections using `เซตว่าง`
# • the `กระจาย` operator — splicing one list into another literal
# • basic access: `longitudo()` and indexed reads via `[n]`
#
# Common mistakes:
# • Using เซตว่าง without an explicit type annotation — เซตว่าง requires a declared collection type like รายการ<T>.
#
# See also: ตาราง, ชุด, ∷, วน
# =============================================================================
# รายการ<T> literals, เซตว่าง, and กระจาย (long-form types — default Faber readability).
# Numeric/tensor modules may use lf32/lu32 sugar; see docs/design/numeric-type-sugar.md.
#
# รายการ<T> ชื่อ ← เซตว่าง -- typed empty collection (forma innata)
# คงที่ _ ชื่อ ← [elem, …] -- list literal
# [กระจาย expr, …] -- splice into literal
#
# GRAMMAR:
# listDecl :← ('แปร' | 'คงที่') 'รายการ<' type '>' ident '←' expr
# listLit :← '[' (expr | กระจาย)* ']'
#
# EXPECTED OUTPUT:
# Scalar longitudo() and indexed accipe only (lista.expected).
main {
const list<int> vacuares ← empty
const _ numeri ← [1, 2, 3, 4, 5]
const _ nomina ← ["Marcus", "Julia", "Gaius"]
const _ vexilla ← [true, false, true]
const _ เมทริกซ์ ← [[1, 2], [3, 4], [5, 6]]
const list<int> primum ← [1, 2, 3]
const list<int> secundum ← [4, 5, 6]
const _ coniuncta ← [spread primum, spread secundum]
const _ aucta ← [0, spread primum, 99]
print vacuares.length()
print numeri.length()
print numeri[0]
print numeri[4]
print nomina.length()
print nomina[1]
print vexilla[0]
print vexilla[2]
print matrix.length()
print เมทริกซ์[1][0]
print coniuncta.length()
print aucta.length()
print aucta[0]
print aucta[4]
}Expected output:
0
5
1
5
3
Julia
verum
verum
3
3
6
5
0
99
radix/corpus/lista/methodi-copiae.fab (canonical · keyword)#
Generic ordered collection type.
# =============================================================================
# รายการ — Generic ordered collection type.
# =============================================================================
#
# What this teaches:
# • สำเนา, slice, and reordering intrinsics — `addita()`, `sectio()`, `prima()`, `ultima()`
# • ordering operations — `inversa()`, `ordinata()`
#
# Common mistakes:
# • Forgetting that sectio(lo, hi) uses an exclusive hi bound — the returned slice may be shorter than expected.
#
# See also: ตาราง, ชุด, ∷, วน
# =============================================================================
# รายการ<T> สำเนา, slice, and ordering intrinsics
#
# res.added(x) | res.slice(lo, hi) | res.take(n) | res.take_last(n) -- views
# res.drop(n) | res.invert() | res.sorted() -- reorder
#
# GRAMMAR:
# listMethod :← expr '.' ('addita' | 'sectio' | 'prima' | 'ultima'
# | 'omissa' | 'inversa' | 'ordinata') '(' args? ')'
#
# EXPECTED OUTPUT:
# [1, 2, 3, 4, 5, 6]
# [2, 3, 4]
# [1, 2]
# [4, 5]
# [3, 4, 5]
# [5, 4, 3, 2, 1]
# [1, 2, 3]
#
# BACKEND: Go e2e whitelist — รายการ intrinsic methods not yet lowered for Go
# (whitelist: รายการ/methodi-copiae.fab).
main {
const _ res ← [1, 2, 3, 4, 5] ∷ list<int>
const _ addita ← res.added(6)
const _ sectio ← res.slice(1, 4)
const _ primaduo ← res.take(2)
const _ ultimaduo ← res.take_last(2)
const _ omissaduo ← res.drop(2)
const _ inversa ← res.invert()
const _ ordinata ← [3, 1, 2].sorted()
print addita
print sectio
print primaduo
print ultimaduo
print omissaduo
print inversa
print ordinata
}Expected output:
[1, 2, 3, 4, 5, 6]
[2, 3, 4]
[1, 2]
[4, 5]
[3, 4, 5]
[5, 4, 3, 2, 1]
[1, 2, 3]
radix/corpus/lista/methodi-mutatio.fab (canonical · keyword)#
Generic ordered collection type.
# =============================================================================
# รายการ — Generic ordered collection type.
# =============================================================================
#
# What this teaches:
# • mutation intrinsics for lists — `appende()`, `decapita()`, `detrahe()`, `inverte()`, `ordina()`
# • contrast between mutation methods and copy-returning participle forms
#
# Common mistakes:
# • Expecting mutation methods (appende, inverte, ordina) to return a new list — they mutate in place and do not return a value.
#
# See also: ตาราง, ชุด, ∷, วน
# =============================================================================
# รายการ<T> mutation intrinsics
#
# res.append(x) | res.remove_first() | res.remove_last() | res.reverse() | res.sort()
#
# GRAMMAR:
# listMethod :← expr '.' ('appende' | 'decapita' | 'detrahe' | 'inverte' | 'ordina') '(' args? ')'
#
# EXPECTED OUTPUT:
# [1, 2]
# 3
# 4
#
# BACKEND: Go e2e whitelist — รายการ intrinsic methods not yet lowered for Go
# (whitelist: รายการ/methodi-mutatio.fab).
main {
var list<int> res ← [3, 1, 2] ∷ list<int>
res.append(4)
const int ∪ none primusremotus ← res.remove_first()
const int ∪ none ultimusremotus ← res.remove_last()
res.reverse()
res.sort()
print res
print primusremotus
print ultimusremotus
}Expected output:
[1, 2]
3
4
radix/corpus/bounded/exact-bound-lattice-decline.fab (supporting · reject)#
Decline: unequal exact bounds on literal elementwise operands reject during typecheck.
# =============================================================================
# Exact-bound รายการ lattice — documented static decline.
# =============================================================================
#
# The two unannotated literals are exact witnesses of capacities 2 and 1.
# Elementwise `+` therefore rejects this mismatch at typecheck with the
# numeric_lista_operator_law issue. Dynamic `list<T>` operands defer their
# equal-length check to runtime; these literal operands do not.
#
# EXPECTED DECLINE: SEM011:numeric_lista_operator_law
# =============================================================================
main {
const list<int> rejected ← [1, 2] + [3]
print rejected
}Expected: compilation rejects this example.