Collection Types

In Nox, there are several collection types, each with their own benefits and trade-offs.

List

A list is a sequence of values, each having the same type. Therefore, a List<T> is said to be a "list of type T". Since all values in the list need to be of the same type, it is said to be a homogeneous data structure.

Example:

[1, 2, 3]            // List<Int>
['hello', 'world']   // List<Str>
[True, False]        // List<Bool>
[Just(42), Nothing]  // List<Maybe<Int>>
[]                   // List<T>

Tuple

A tuple can hold a handful of values, each having their own type.

Example:

(0, 0)                // (Int, Int)
(1, 2, 3)             // (Int, Int, Int)
('hello', 42, True)   // (Str, Int, Bool)

0-tuples and 1-tuples don't exist in Nox.

Last updated