Generic ordered collection type.
Aliases: array, list
Syntax: lista<T>
Category
collection
Related
Examples
examples/corpus/lista/lista.fab (canonical · existing-home)
Generic ordered collection type.
# lista<T> literals, vacua, and sparge (long-form types — default Faber readability).
# Numeric/tensor modules may use lf32/lu32 sugar; see docs/design/numeric-type-sugar.md.
#
# lista<T> nomen ← vacua -- typed empty collection (forma innata)
# fixum _ nomen ← [elem, …] -- list literal
# [sparge expr, …] -- splice into literal
#
# GRAMMAR:
# listDecl :← ('varia' | 'fixum') 'lista<' type '>' ident '←' expr
# listLit :← '[' (expr | sparge)* ']'
#
# EXPECTED OUTPUT:
# Scalar longitudo() and indexed accipe only (lista.expected).
incipit {
fixum lista<numerus> vacuares ← vacua
fixum _ numeri ← [1, 2, 3, 4, 5]
fixum _ nomina ← ["Marcus", "Julia", "Gaius"]
fixum _ vexilla ← [verum, falsum, verum]
fixum _ matrix ← [[1, 2], [3, 4], [5, 6]]
fixum _ prima ← [1, 2, 3]
fixum _ secunda ← [4, 5, 6]
fixum _ coniuncta ← [sparge prima, sparge secunda]
fixum _ aucta ← [0, sparge prima, 99]
nota vacuares.longitudo()
nota numeri.longitudo()
nota numeri[0]
nota numeri[4]
nota nomina.longitudo()
nota nomina[1]
nota vexilla[0]
nota vexilla[2]
nota matrix.longitudo()
nota matrix[1][0]
nota coniuncta.longitudo()
nota aucta.longitudo()
nota aucta[0]
nota aucta[4]
}Expected output:
0
5
1
5
3
Julia
verum
verum
3
3
6
5
0
99examples/corpus/lista/methodi-copiae.fab (canonical · existing-home)
Generic ordered collection type.
# lista<T> copy, slice, and ordering intrinsics
#
# res.addita(x) | res.sectio(lo, hi) | res.prima(n) | res.ultima(n) -- views
# res.omissa(n) | res.inversa() | res.ordinata() -- 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 — lista intrinsic methods not yet lowered for Go
# (whitelist: lista/methodi-copiae.fab).
incipit {
fixum _ res ← [1, 2, 3, 4, 5] ∷ lista<numerus>
fixum _ addita ← res.addita(6)
fixum _ sectio ← res.sectio(1, 4)
fixum _ primaduo ← res.prima(2)
fixum _ ultimaduo ← res.ultima(2)
fixum _ omissaduo ← res.omissa(2)
fixum _ inversa ← res.inversa()
fixum _ ordinata ← [3, 1, 2].ordinata()
nota addita
nota sectio
nota primaduo
nota ultimaduo
nota omissaduo
nota inversa
nota 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]
examples/corpus/lista/methodi-mutatio.fab (canonical · existing-home)
Generic ordered collection type.
# lista<T> mutation intrinsics
#
# res.appende(x) | res.decapita() | res.detrahe() | res.inverte() | res.ordina()
#
# GRAMMAR:
# listMethod :← expr '.' ('appende' | 'decapita' | 'detrahe' | 'inverte' | 'ordina') '(' args? ')'
#
# EXPECTED OUTPUT:
# [1, 2]
# 3
# 4
#
# BACKEND: Go e2e whitelist — lista intrinsic methods not yet lowered for Go
# (whitelist: lista/methodi-mutatio.fab).
incipit {
varia _ res ← [3, 1, 2] ∷ lista<numerus>
res.appende(4)
fixum _ primusremotus ← res.decapita()
fixum _ ultimusremotus ← res.detrahe()
res.inverte()
res.ordina()
nota res
nota primusremotus
nota ultimusremotus
}Expected output:
[1, 2]
3
4