Scripting Guide > Data Structures > Lists in JSL Scripts > List Operators and Functions
Publication date: 07/08/2024

List Operators and Functions

Table 7.1 describes list operators and their JSL syntax.

Table 7.1 List Operators

Operator and Function

Syntax

Explanation

As List()

As List(matrix)

Returns the matrix as a list. A matrix with multiple columns is returned as a list of lists, one list per row.

=

+=

-=

*=

/=

++

--

Assign()

Add To()

SubtractTo()

MultiplyTo()

DivideTo()

Post Increment()

Post Decrement()

{list} = {list}

{list} += value

{list} -= {list}

...

If the target of an assignment operator is a list and the value to be assigned is a list, then it assigns item by item. The ultimate values in the left list must be L-values (in other words, names capable of being assigned values).

Notes:

If you want to test equality of lists, use ==, not =.

JMP does not have pre-increment or pre-decrement operators. Instead, use the Add To() operator, which is (+=), or the Subtract To() operator, which is (-=).

||=

Concat To()

Concat To(list1, list2, ...)

Inserts the second and subsequent lists at the end of the first list.

||

Concat()

Concat(list1, list2, ...);

Returns a copy of the first list with any additional lists inserted at after it.

Eval List()

Eval List(list)

Returns a list of the evaluated expressions inside list. See Evaluate Lists.

Insert Into()

Insert Into(list, x, <i>)

Inserts a new item (x) into the list at the given position (i). If i is not given, the item is added to the end of the list. This function does change the original list.

Insert()

list = Insert(list, x, <i>)

Returns a copy of the list with a new item (x) inserted into the list at the given position (i). If i is not given, the item is added to the end of the list. This function does not change the original list.

Is List()

Is List(arg)

Returns true (1) if arg is a classical list (in other words, one that would result from the construction by List(items) or {items}) and returns false (0) otherwise. An empty list is still a list, so IsList({ }) returns true. If miss=., then IsList(miss) returns false, not missing.

{ }

List

List(a, b, c)

{a, b, c}

Constructs a list from a set of items. An item can be any expression, including other lists. Items must be separated by commas. Text should either be enclosed in double quotation marks ( " " ) or stored in a variable and called as that variable.

N Items

N Items(list)

Returns the number of elements in the list specified. Can be assigned to a variable.

Remove From()

Remove From(list, <i>, <n>)

Deletes n items from the list, starting from the indicated position (i). If n is omitted, the item at i is deleted. If n and i are omitted, the item at the end is removed. This function does change the original list.

Remove()

Remove(list, <i>, <n>)

Returns a copy of the list with the n items deleted, starting from the indicated position (i). If n is omitted, the item at i is deleted. If n and i are omitted, the item at the end is removed. This function does not change the original list.

Reverse Into()

Reverse Into(list)

Reverses the order of the items in the list. This function does change the original list.

Reverse()

Reverse(list)

Returns a copy of the list with the items in reverse order. This function does not change the original list.

Shift Into()

Shift Into(list, <n>)

Shifts n items from the front of the list to the end of the list. If n is omitted, the first item is moved to the end of the list. This function does change the original list.

Shift()

Shift(list, <n>)

Returns a copy of the list with n items shifted from the front of the list to the end of the list. If n is omitted, the first item is moved to the end of the list. This function does not change the original list.

Sort Ascending()

Sort Ascending(list)

Returns a copy of the list sorted in ascending order. This function does not change the original list.

Sort Descending()

Sort Descending(list)

Returns a copy of the list sorted in descending order. This function does not change the original list.

Sort List Into()

Sort List Into(list)

Sorts the list in ascending order. This function does change the original list.

Sort List()

Sort List(list)

Returns a copy of the list sorted in ascending order. This function does not change the original list.

[ ]

Subscript()

list[i]

x = list[i]

list[i] = value

a[b, c]

Subscript(a, b, c)

Subscripts for lists extract the ith item from the list. Subscripts can in turn be lists or matrices.

Substitute()

Substitute(list, pattExpr1, replExpr1, ...)

Returns a copy of a string, list, or expression, replacing instances of each pattern expression with the corresponding replacement expression. See Substitute and Substitute Into Functions.

Substitute Into()

Substitute Into(list, pattExpr1, replExpr1, ...)

Changes a string, list, or expression, replacing instances of each pattern expression with the corresponding replacement expression. Note: The list or expression must be a variable. See Substitute and Substitute Into Functions.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).