The functions for manipulating lists can also operate on most expressions. Be sure to quote the expression with Expr(). For example:
As with lists, remember that the first argument for in-place functions must be an L-value. An L-value is an entity such as a global variable whose value can be set. In-place functions are those that operate on lists or expressions directly. They have From or Into in their names (for example, Remove From and Insert Into). They do not return a result; you have to show the expression to see the result.
Show( polynomial );
For the not-in-place functions, you must either state the expression directly or else quote a name that evaluates to an expression using NameExpr. Such functions do not have From or Into in their names. They return manipulated lists or expressions without changing the original list or expression given in the first argument.
Substituting is extremely powerful; please review the earlier discussion Substituting. Here are a few notes regarding substituting for expressions.
Substitute(pattern,name,replacement) substitutes for names in expressions
NameExpr() looks through the name but copies instead of evaluates:
a = Expr(
Show( Name Expr( a ) );
Substitute() evaluates all its arguments, so they must be quoted correctly:
Show( Name Expr( b ) );
SubstituteInto() needs an L-value, so the first argument is not quoted:
Show( Name Expr( a ) );
Substitute() is useful for changing parts of expressions, such as in the following example that tests the Is functions:
test = Expr(
Show( m );
You can use SubstituteInto() to have JMP solve quadratic equations. The following example solves 4x2 - 9 = 0:
x = {Expr(
), Expr(
Show( x ); // see the result of substitution
The functions for manipulating lists and expressions are discussed in the previous section, Manipulating lists, and summarized in Functions for Manipulating Lists or Expressions.
Copies the list or expression, deleting the item(s) at the indicated position. If position is omitted, items are deleted from the end. Position can be a list of positions. An extra argument, n, deletes n items instead of just 1.
|
||
Inserts a new item into the list or expression at the given position. If position is not given, it is inserted at the end.
|
||
Shift an item or n items from the front to the back of the list or expression. Shift items from back to front if n is negative.
|
||
Sort the elements of a list or the terms of an expression. Numbers sort low, followed by the name value of names, strings, or operators. For example 1+2 is lower than 1-2 because the name value Add sorts lower than the name value Subtract. {1,2} sorts lower than {1,3}, which sorts lower than {1,3,0}. {1000} sorts lower than {“a”}, but {a} and {“a”} sort as equal.
|
||
Creates a matrix of subscript positions where the values in matrix A match the values in matrix B. A must be a matrix sorted in ascending order.
|
||
Finds all matches to the pattern in the list or expression, and replaces them with the replacement expression. Each pattern must be a name. The second and third arguments are evaluated before they are applied, so most of the time you must quote them with an Expr function. To delay evaluating an argument, use Name Expr instead of Expr. You can list multiple pattern-replacement pairs for multiple substitutions in one statement.
|
||