Collections

The basic collection types are arrays, strings, and tables.

An identical double-ended queue (deque) API is supported by both arrays and strings. A string can be thought of as an array which only contains characters.

Collections

len

Returns the number of items in a collection.

empty?

Returns #t if a collection contains no items.

access

Retrieves an item from a collection.

access=

Mutates an item in a collection.

has?

Returns #t if a collection contains a particular item.

remove!

Removes an item from a collection, and returns it.

del!

Deletes an item from a collection, without returning it.

clear!

Deletes all items from a collection.

map-syntax

Maps a function over a collection, preserving syntax information.

Arrays

arr

Constructs a new, mutable array.

arr-from-elem

Constructs a new, mutable array by repeating a value.

Deques

push!

Appends one or more elements to the end of a deque.

push-start!

Prepends one or more elements to the beginning of a deque.

pop!

Removes the deque's last element, and returns it.

pop-start!

Removes the deque's first element, and returns it.

insert!

Inserts one or more elements into a deque.

grow!

Increases a deque's size.

shrink!

Reduces a deque's size.

swap-remove!

Swaps an element with the deque's last element, then removes it and returns it.

swap-remove-start!

Swaps an element with the deque's first element, then removes it and returns it.

sort

Returns a sorted copy of a deque.

sort!

Sorts a deque in-place.

starts-with?

Tests whether one deque is the prefix of another.

ends-with?

Tests whether one deque is the suffix of another.

position

Searches within a deque.

rposition

Searches backwards within a deque.

rev!

Reverses a deque in-place.

map!

Maps a function over a deque in-place.

retain!

Filters a deque in-place.

join

Combines an array of deques into one deque.

Tables

tab

Constructs a table.

extend!

Inserts any number of key/value pairs into a table.

keys-eqv?

Returns #t if all of its arguments would occupy the same table entry when used as keys.

Numbers
Strings and Text