Working with lists
A list is a named entity that can contain multiple values of the same type. Lists occur as follows:
- A field that allows multiple values may contain a list rather than a scalar value.
- Some @functions return a list.
- Constants and variables can be specified as lists as well as scalar values. The syntax is multiple elements separated by colons; for example, "London" : "New York" : "Tokyo" is a string list constant of three elements.
- Since list concatenation has the highest precedence, list elements that are expressions must be in parentheses if the expression applies only to that element. For example, write 1:2:(-3):4, not 1:2:-3:4, if 3 is negative and 4 is not.
- Lists can be subscripted to read (but not write) elements. For example, Categories[2] is the second element of the Categories field.
- Operators combine lists on a pair-wise or permuted basis.
Lists provide limited iteration because a list operation applies the operation to each element of the list, like processing an array in a loop.
The following @functions deal specifically with lists.
Function |
Description |
---|---|
@Compare |
Compares two lists pair-wise. |
@Count(list) |
Determines the number of elements in a list, returning 1 if the value it is evaluating is a null string or not a list. |
@Elements(list) |
Determines the number of elements in a list, returning 0 if the value it is evaluating is a null string or not a list. |
@Explode(string) |
Converts a text string into a text list. Spaces, commas, semicolons, and newlines separate elements in the string. |
@Explode(string ; separators) |
Converts a text string into a text list; the second parameter specifies the separators (except newlines) for elements in the string. |
@Explode(string ; separators ; includeEmpties) |
Converts a text string into a text list; @True as the third parameter includes empty list elements where consecutive separators occur. |
@Explode(string ; separators ; includeEmpties ; newlineAsSeparator) |
Converts a text string into a text list; @False as the fourth parameter excludes newlines as separators. |
@Explode(dateRange) |
Converts a date range into a list of dates. The argument must be a time-date value; the return value is a text list. |
@Implode(list) |
Converts a text list to a text string, using spaces to separate elements. |
@Implode(list ; separator) |
As shown previously, but the second parameter specifies the separator for elements in the string. |
@IsMember(string ; list) |
Determines if a string is a member of a list. Returns True (1) or False (0). |
@IsMember(list1; list2) |
Determines if a list is contained in another list. Returns True (1) or False (0). |
@IsNotMember(string ; list) |
Determines if a string is not a member of a list. Returns True (1) or False (0). |
@IsNotMember(list1; list2) |
Determines if a list is not contained in another list. Returns True (1) or False (0). |
@Keywords(list1; list2) |
Locates words in list1 that match words in list2. Word separators are " , ? ! ; : [ ] { } < > |
@Keywords(list1; list2; separator) |
As shown previously, but the second parameter specifies the word separators. |
@Max (number or numberlist) |
Returns the largest number in the list. |
@Max (number or numberlist ; number or numberlist) |
Returns the larger number of two numbers or a number list of the largest numbers resulting from a pair-wise computation of two number lists. |
@Member(value ; list) |
Determines the position of a value in a string list. |
@Min (number or numberlist) |
Returns the smallest number in the list. |
@Min (number or numberlist ; number or numberlist) |
Returns the smaller number of two numbers or a number list of the smallest numbers resulting from a pair-wise computation of two number lists. |
@Nothing |
Adds nothing to a transformed list. |
@Replace(list1; list2; list3) |
Replaces values in list1 that match values in list2 with the corresponding values in list3. |
@Sort( list ;[order]) |
Sorts a list. Order is [Ascending] (default) or [Descending]. |
@Subset(list ; n) |
Extracts n number of values from the list. Use -n to extract right to left. |
@Transform(list ; name ; formula) |
Applies a formula to each element of a list. |
@Unique(list) |
Removes duplicate values from a string list. |
@Unique |
Returns a random, unique text value. |