langur

arrays

Array literals are built with square brackets that are clearly not an indexing operator.

Arrays may contain any other langur data structures, and they may be mixed freely.

Arrays may be appended with the concatenation operator (tilde) or with the more() function. Like concatenation, the more() function creates a new array and does not modify the original.

[1, 2, 3] ~ [4, 5, 6, 7] == [1, 2, 3, 4, 5, 6, 7] # true

quoted word arrays

As a semantic convience, string arrays may use a shortened syntax, beginning with a letter w (interpreting escape codes) or W (not interpreting escape codes). Quote mark pairs allowed are the same as for string and regex literals.

A quoted word array uses spacing to separate word strings. This is similar to the qw() construct used in Perl.

w/1 2 3 you know/ == ["1", "2", "3", "you", "know"]

w/1 2 3 you\x20know/ == ["1", "2", "3", "you know"]

W/1 2 3 you\x20know/ == ["1", "2", "3", "you\\x20know"]

You can use blockquotes for quoted word arrays (see strings).

A quoted word array not using a blockquote cannot include line returns.

Allowed characters are the same as for string literals.

Interpolation is not valid, so there is no $w// or $W// literal.

array no-op token

You can use an array of functions and no-ops with the map() function, as in the following example.

val .isbn13checkdigit = f(var .s) { .s = replace(.s, RE/[\- ]/) matching(re/^[0-9]{13}$/, .s) and fold(f{+}, map([_, f .d x 3], map(f .c-'0', s2cp .s))) rem 10 == 0 }

array generation

Besides using square brackets to generate an array, you can use the built-in arr() function. This will generate an array with a specified number of elements. Optionally, you can include a value to set each element to (default null).

You can also use array multiplication.

[1, 2, 3, 4] x 3 == [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]

A negative number on array multiplication acts like 0 and does not throw an exception.