Faber has several compiler-owned collection types. Their canonical methods live in the compiler, not in the standard library.
Lista — ordered dynamic collection
fixum lista<numerus> empty ← vacua
fixum _ numbers ← [1, 2, 3, 4, 5]
fixum _ names ← ["Marcus", "Julia", "Gaius"]
fixum _ nested ← [[1, 2], [3, 4]]Spread with sparge:
fixum _ a ← [1, 2, 3]
fixum _ b ← [4, 5, 6]
fixum _ combined ← [sparge a, sparge b]
fixum _ headed ← [0, sparge a, 99]Key methods: longitudo, accipe, appende, summa, primus, novissimus.
Tabula — key-value map
fixum tabula<textus, numerus> scores ← { "alice": 10, "bob": 20 }Tensor — dense fixed-shape buffer
fixum tensor<fractus<f32>, []> scalar ← vacua
fixum tensor<numerus, [4]> vector ← [1, 2, 3, 4] ↦ tensor<numerus, [4]>
fixum numerus ∪ nihil first ← vector[0]Tensor sugar (numeric-heavy code):
fixum tf32[] seed ← vacua
fixum tf32[4] lanes ← seed.strue([1.0, 2.0, 3.0, 4.0], [4])Key methods: forma, accipe, ponde, crea, structa, strue, plus
elementwise arithmetic, matrix multiplication (multiplicatio), and
reductions (summa, productum).
Sparsa — sparse fixed-shape buffer
fixum sparsa<fractus<f32>, [2, 3]> sparse ← vacua
sparse.ponde([0, 1], 4.0)
sparse.ponde([1, 2], 9.0)
# accipe returns the stored value, here 4.0
nota sparse.accipe([0, 1])
# count of stored entries
nota sparse.nonnihil()Conversion between dense and sparse:
fixum tf32[2, 2] dense ← [[1.0, 0.0], [0.0, 2.0]] ↦ tf32[2, 2]
fixum sf32[2, 2] sparse ← dense ↦ sf32[2, 2]
fixum tf32[2, 2] roundtrip ← sparse ↦ tf32[2, 2]Cursors — lazy streams
cursor<T> is a lazy stream type. Created from collection iterators,
tuus views, or generator functions. Consumed via itera ex:
fixum _ items ← [1, 2, 3]
itera ex items fixum item {
nota item
}Intervallum — ranges
# exclusive range: 0, 1, 2, 3, 4
itera ab 0‥5 fixum i {
nota i
}
# inclusive range: 0, 1, 2, 3, 4, 5
itera ab 0…5 fixum i {
nota i
}‥ is exclusive range endpoint; … is inclusive.