types

list

Ordered collections of values and the methods available on them.

A list is an ordered collection of values. As a schema field it is written tags: list for any values, or tags: list of string for a typed list. A literal uses brackets, as in [1, 2, 3].

marreta
items = [3, 1, 2]
sorted = items.sort()
has_two = items.includes(2)

Methods

NameSignatureSummary
list.lengthlength()Returns the number of items.
list.empty?empty?()Returns whether the list is empty.
list.firstfirst()Returns the first item, or null.
list.lastlast()Returns the last item, or null.
list.pushpush(value)Appends a value and returns the list.
list.includesincludes(value)Returns whether the list includes a value.
list.sliceslice(start, end)Returns a sub-list.
list.sortsort()Returns a sorted list.
list.reversereverse()Returns a reversed list.
list.uniqueunique()Returns the distinct values.
list.joinjoin(separator)Joins the values into a string.
list.flattenflatten()Flattens one level of nesting.
list.zipzip(other)Pairs two lists of the same length.
list.sumsum()Sums a numeric list.
list.meanmean()Returns the mean, or null when empty.
list.medianmedian()Returns the median, or null when empty.
list.std_devstd_dev()Returns the population standard deviation.