ApasScript.

Collections

len

The number of items in an array or list, characters in text, or entries in a map.

append

Adds an item to the end. Given a name, the array itself grows (like xs.append(v)); a non-number item turns a number array into a list.

concat

A new array or list: the first followed by the second.

reverse

A new array or list in reverse order. (On a linked list, reverse animates the in-place reversal -- see Data Structures.)

sort

A new array sorted from smallest to largest, compared exactly (sqrt(2) sorts after 1.4142). Quantities sort by their value in one unit (250 mN before 3 N).

contains

Whether an array or list has an item equal to the value, text contains a piece of text, or a map has a key. (On a set, set membership -- see Sets.)

indexOf

The position (from 0) of the first item equal to the value, or -1 if there is none.

keys

A map's keys in the order they were added (a record's field names).

values

A map's values in the order their keys were added.

has

Whether a map has the key.

delete

Removes a key (and its value) from a map, and shows the map.

filter

The items of an array or list for which a condition holds, in their order. The item is called x in the condition, or the name given third. The same as xs[condition], e.g. xs[xs > 20].

countWhere

How many items of a collection satisfy a condition, or how many tuples, orderings or subsets of its items do. countWhere(xs, condition) counts the items as filter selects them (the item called x, or the name given third); xs may be a whole number n for the numbers 1..n. countWhere(xs, fn(x, y) condition) counts the ordered pairs (triples, ... : one entry per parameter of the function; an item may repeat) for which the function holds; a third argument "distinct" allows no repeated item (the k-permutations), "sets" counts the subsets of that many items (each once, in the list's order), and "permutations" tests every ordering of the whole list, given to a function of one parameter as a list (up to 9 items). Up to a million tuples; the count is exact. For an unordered pair with repeats count sets and singles separately. relationWhere(A, B, rule, x, y) lists the pairs instead of counting them.

permutations

Every ordering of the items of a list, as a list of lists (n! of them: up to 9 items). xs may be a whole number n for 1..n. filter and countWhere take the result; countWhere(xs, fn(p) ..., "permutations") counts without listing.

tuples

Every ordered k-tuple of the items of a list, an item allowed to repeat, as a list of lists (n^k of them, up to a million). xs may be a whole number n for 1..n.

subsets

Every subset of k items of a list, each in the list's order, as a list of lists (nCr(n, k) of them, up to a million). xs may be a whole number n for 1..n. powerSet gives the subsets of every size.

slice

The items from position i up to (not including) j, as xs[i:j]; without j, to the end. Positions count from 0; a negative one counts from the end. Text is sliced by character.