An expression combines operators to calculate its result.
Each operator defines its accepted arguments and result. The Arguments column
gives argument names in their accepted order. Stardust rejects the wrong
number of arguments. It also rejects an argument of the wrong type.
Operators that accept more than two arguments use a fold, a chain, or all
arguments together.
A fold applies the operator again to its own result. +, -, * and / have
this shape, and [+ 1 2 3] is [+ [+ 1 2] 3]. A fold goes from left to right,
which changes the result of - and /.
xor has this shape. [xor a b c] is [xor [xor a b] c], and xor is
therefore true when the number of true arguments cannot be divided by 2. Three
true arguments give true.
A chain applies the operator to each pair of adjacent arguments. <, <=, >>= and = have this shape. [< 1 5 10] requires 1 to be less than 5 and 5 to be less than 10.
It does not compare a true or false value against 10.
rem and % give the same result when both arguments are more than zero. The
results are different when one argument is less than zero. rem keeps the sign
of the first argument, and % keeps the sign of the second argument.
One operator gives the same type of limit on each side. If the two limits are
not the same type, use and with two comparisons. This example accepts a value
at the low limit but not at the high limit.
pow gives an integer when both numbers are integers and the power is zero or
more. Such a result must fit in 64 bits, as for *. Other powers give a float.
sqrt requires a number that is not negative, and log and log2 require a
number greater than zero. A result that is not finite is an error, as for /.
seededRand gives the same number for the same arguments on every machine and
every run. A value that must be irregular but must not change between runs
therefore needs no stored database field.
The text in one case, or without spaces at its ends
textLength
text
The number of characters
camel, snake, screamingSnake, kebab, pascal
text
The text in one name style
escape
text
The text with HTML characters replaced
contains, hasPrefix
part, text
True or false
hasSuffix
text, suffix
True or false
trimPrefix
prefix, text
Text without that prefix
trimSuffix
text, suffix
Text without that suffix
indexOf, lastIndexOf
needle, text
One-based character position, or 0
repeat
count, text
The text repeated
split, splitAfter
separator, text
The separator first, then the text
join
separator, list
The separator first, then the list
replace
old, new, text
The old text, the new text, then the text
substring
start, text or start, size, text
The start, and an optional size. Both accept negative values
format
template, value, values…
The template first, then its arguments
Stardust counts and cuts text in characters. [textLength héllo] gives 5.
contains, hasPrefix and hasSuffix give false when an argument is not a text, null included.
[hasPrefix a 7] is false. The other text operators fail on a value that is not a text.
format uses {} in sequence and {0} by position. {{}} gives one brace.
A specification after : must suit the type of its value. An integer accepts
b, c, d, o, x, X and U. A float accepts e, E, f, F, g
and G, and a text accepts s. A float specification over an integer is an
error, as [format '{:.2f}' 42] is.
Each operator in this group has a function first. The input
list is last, including forms with an initial value or direction. A built-in
operator can be a function, as in [reduce + 0 [list 1 2 3]].
Operator
Arguments
Result
map, filter
function, list
A new list
all, none, any, one
function, list
True when that number of items agree
find, findLast
function, list
The first or last item that agrees, or null
findIndex, findLastIndex
function, list
Zero-based position, or -1
groupBy
function, list
A map from each calculated key to its items
sortBy
function, list or function, direction, list
The list in the order of a calculated key, with an optional direction
reduce
function, initial, list
The function, the first value, then the list
count, sum
function, list
Counts or adds only the items that the function accepts
isNull, isBool, isText, isInt, isFloat, isNumber, isEntity,
isTagged, isList and isMap each have one argument. Each one gives true
or false. isInt and isFloat separate the two kinds of number. isNumber
accepts both kinds.
A pattern can start and end with / to add flags. The i flag ignores case.
The m flag lets ^ and $ match at each line. The x flag ignores spaces
in the pattern. The u flag reads the text as Unicode.
A pattern accepts alternation a|b and classes [0-9] and [^0-9]. It also
accepts the ASCII shorthands \d\s\w and their negations. The wildcard
is .. Repeats use *, +, ?, or {1,2}, with ? for non-greedy
matching. Groups use (a) or (?:a). Anchors are ^ and $, and word
boundaries are \b and \B.
A pattern can have 9 groups. Stardust rejects a pattern with more groups.
It also rejects group references such as \1, look-ahead (?=a),
look-behind (?<=a), and group names such as (?<year>a).
Runtime_Failure: The regular expression is not valid.
Matching examines each text position one time. It does not try each choice
again, so the following expression gives false immediately:
[reMatch (a+)+$ aaaaaaaaaaaaaaaaaaaaaaaa!].