For the latest version of JMP Help, visit JMP.com/help.


Publication date: 04/28/2021

List Functions

As List(matrix)

Description

Converts a matrix into a list. Multi-column matrices are converted to a list of row lists.

Returns

A list.

Argument

matrix

Any matrix.

Concat Items({string1, string2, ...}, <delimiter>})

Description

Converts a list of string expressions into one string, with each item separated by a delimiter. The delimiter is a blank, if unspecified.

Returns

The concatenated string.

Arguments

string

any string

delimiter

an optional string that is placed between each item. The delimiter can be more than one character long.

Example

str1 = "one";
str2 = "two";
str3 = "three";
 
comb = Concat Items({str1, str2, str3});

"one two three"

comb = Concat Items({str1, str2, str3}, " : ");

"one : two : three"

del = ",";
comb = Concat Items({str1, str2, str3}, del);

"one,two,three"

Eval List({list})

Description

Evaluates expressions inside list.

Returns

A list of the evaluated expressions.

Arguments

list

A list of valid JSL expressions.

Insert(source, item, <position>)

Insert(source, key, value)

Description

Inserts a new item into the source at the given position. If position is not given, item is added to the end.

For an associative array: Adds the key into the source associative array and assigns value to it. If the key exists in source already, its value is overwritten with the new value.

Arguments

source

A string, list, expression, or associative array.

item or key

Any value to be placed within source. For an associative array, key might or might not be present in source.

position

Optional numeric value that specifies the position in source to place the item into.

value

A value to assign to the key.

Insert Into(source, item, <position>)

Insert Into(source, key, value)

Description

Inserts a new item into the source at the given position in place. The source must be an L-value.

Arguments

source

A variable that contains a string, list, display box, expression, or associative array.

item or key

Any value to be placed within source. For an associative array, key might or might not be present in source.

position

Optional numeric value that specifies the position in source to place the item into.

value

A value to assign to the key.

Is List(x)

Description

Returns 1 if the evaluated argument is a list, or 0 otherwise.

Items(string, <Delimiter>, <Include Boundary Delimiters(Boolean)>)

Description

Returns a list of (possibly empty) sub-strings separated by exactly one of any of the characters specified in the delimiter argument.

Arguments

string

The string being evaluated.

Delimiter

(Optional) The character used as a boundary. If delimiter is absent, an ASCII space is used. If delimiter is the empty string, each character is treated as a separate word. If delimiter is an empty string, each character is treated as a spate word.

Include Boundary Delimiters(Boolean)

(Optional) Includes the delimiters in the returned string.

Example

Items( "http://www.jmp.com", ":/." );

{"http", "", "", "www", "jmp", "com"}

Items(",toy,", ",");

{"toy"}

Items(",toy,", ",", Include Boundary Delimiters( 1 ));

{"", "toy", ""}

// There is no text between the boundary (the beginning of the string) and the comma delimiter, so you get an empty string. The same priniciple applies to the delimiter at the end of the string.

List(a, b, c, ...)

{a, b, c, ...}

Description

Constructs a list from a set of items.

N Items(source)

Description

Determines the number of elements in the source specified.

Returns

For a list or display box, the number of items in the list or display box is returned. For an associative array, the number of keys is returned. For a matrix, the number of elements in the matrix is returned. For a namespace, the number of functions and variables in the namespace is returned. For a class object, the number of methods, functions, and variables is returned.

Arguments

source

A list, associative array, matrix, display box, or namespace.

Remove(source, position, <n>)

Remove(source, {items})

Remove(source, key)

Description

Deletes the n item(s), starting from the indicated position. If n is omitted, the item at position is deleted. If position and n are omitted, the item at the end is removed. For an associative array: Deletes the key and its value.

Returns

A copy of the source with the items deleted.

Arguments

source

A string, list, expression, or associative array.

position or key

An integer (or list of integers) that points to a specific item (or items) in the list or expression.

n

(Optional) An integer that specifies how many items to remove.

Remove From(source, position, <n>)

Remove From(source, key)

Description

Deletes the n item(s) in place, starting from the indicated position. If n is omitted, the item at position is deleted. If position and n are omitted, the item at the end is removed. For an associative array: Deletes the key and its value. The source must be an L-value.

Returns

The original source with the items deleted.

Arguments

source

A string, list, expression, display box, or associative array.

position or key

An integer (or list of integers) that points to a specific item (or items) in the list or expression.

n

(Optional) An integer that specifies how many items to remove.

Reverse(source)

Description

Reverse order of elements or terms in the source.

Argument

source

A string, list, or expression.

Reverse Into(source)

Description

Reverses the order of elements or terms in source in place.

Argument

source

A string, list, display box, or expression.

Shift(source, <n>)

Description

Shifts an item or n items from the front to the back of the source.

Arguments

source

A string, list, or expression.

n

(Optional) An integer that specifies the number of items to shift. Positive values shift items from the beginning of the source to the end. Negative values shift items from the end of the source to the beginning. The default value is 1.

Shift Into(source, <n>)

Description

Shifts items in place.

Arguments

source

A string, list, display box, or expression.

n

(Optional) An integer that specifies the number of items to shift. Positive values shift items from the beginning of the source to the end. Negative values shift items from the end of the source to the beginning. The default value is 1.

Sort List({list }|expr)

Description

Sort the elements or terms of list or expr.

Sort List Into({list }|expr)

Description

Sort the elements or terms of list or expr in place.

Substitute("string", "substring", "replacementString", ...)

Substitute({list }, listItem, replacementItem, ...)

Substitute(Expr(sourceExpr), Expr(findExpr), Expr(replacementExpr), ...)

Description

This is a search and replace function. It searches for a specific portion (second argument) of the source (first argument), and replaces it (third argument).

If a string, finds all matches to substring in the source string, and replaces them with the replacementString.

If a list, finds all matches to listItem in the source list, and replaces them with the replacementItem.

If an expression, finds all matches to the findExpr in the sourceExpr, and replaces them with the replacementExpr. Note that all expressions must be enclosed within an Expr() function.

Arguments

string, list, sourceExpr

A string, list, or expression in which to perform the substitution.

substring, listItem, findExpr

A string, list item, or expression to be found in the source string, list, or expression.

replacementString, replacementItem, replacementExpr

A string, list item, or expression to replace the found string, list item, or expression.

Substitute Into("string", substring, replacementString, ...)

Substitute Into(list, listItem, replacementItem, ...)

Substitute Into(Expr(sourceExpr), Expr(findExpr), Expr(replacementExpr), ...)

Description

This is a search and replace function, identical to Substitute() except in place. It searches for a specific portion (second argument) of the source (first argument), and replaces it (third argument). The first argument must be an L-value.

If a string, finds all matches to substring in the source string, and replaces them with the replacementString.

If a list, finds all matches to listItem in the source list, and replaces them with the replacementItem.

If an expression, finds all matches to the findExpr in the sourceExpr, and replaces them with the replacementExpr. Note that all expressions must be enclosed within an Expr() function.

Arguments

string, list, sourceExpr

A string, list, or expression in which to perform the substitution.

substring, listItem, findExpr

A string, list item, or expression to be found in the source string, list, or expression.

replacementString, replacementItem, replacementExpr

A string, list item, or expression to replace the found string, list item, or expression.

Words("string", <delimiter>)

Description

Extracts the words from string according to the delimiters given. The default delimiter is ASCII whitespace. If you include a second argument, any and all characters in that argument are considered delimiters. If delim is an empty string, each character is treated as a separate word.

Examples

Words( "the quick brown fox" );

{"the","quick","brown","fox"}

Words( "Doe, Jane P.",", ." );

{"Doe","Jane","P"}

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