selection from an expression
removal from an expression
selection or removal from an expression
Objects Supporting select, remove, and selectremove
select(f, e, b1, ..., bn)
select[flatten](f, e, b1, ..., bn)
select[inplace](f, e, b1, ..., bn)
remove(f, e, b1, ..., bn)
remove[flatten](f, e, b1, ..., bn)
remove[inplace](f, e, b1, ..., bn)
selectremove(f, e, b1, ..., bn)
selectremove[flatten](f, e, b1, ..., bn)
selectremove[inplace](f, e, b1, ..., bn)
b1, ..., bn
(optional) extra arguments
The select function selects the operands of the expression e which satisfy the Boolean-valued procedure f, and creates a new object of the same type as e. Those operands for which f does not return true are discarded in the newly created object.
When e is an ordered expression, such as a list or unevaluated function call, the operands of the output retain their relative order. If the expression e is an expression of type ^ and the result consists only of an exponent with a null base, then the output is undefined.
The remove function does the opposite of select. It removes the operands of e which satisfy f and creates a new object.
The selectremove function behaves in the same manner as select(..) and remove(..), except that the result is computed efficiently, in a single pass over expression e.
Additional arguments b1, ..., bn are passed to f.
When e is an Array, Vector, Matrix, or table, the select[flatten] form can be used. This causes the result to be flattened to a one-dimensional structure with all discarded elements removed (as opposed to having the discarded elements replaced with NULL).
When e is an Array, Matrix, Vector, table, or an object implementing a mutable container, the select[inplace] form can be used. This causes the selection to be applied to the container in-place (for example, in the case of select[inplace], the non-selected entries in the container are removed from e itself). When selectremove[inplace] is called, the first result is computed in-place, and the removed elements are returned in a new container that is returned as the second result.
A typical application that uses select and remove is to split the factors of a product, e, into those which depend on a variable x and those which do not (that is, constants). This can be accomplished by using v := select(has,e,x); followed by c≔remove⁡has,e,x. It is more efficient, however, to use v,c≔selectremove⁡has,e,x. Do not try to compute c≔ev. Because of the way Maple simplifies expressions, factors do not cancel out in general. See the last example below.
The following objects support the select, remove, and selectremove commands with a separate implementation. See the help pages linked below for more details.
Using the flatten and inplace options together is permitted, but is not thread safe.
The select, remove and selectremove commands are thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
The following example selects any entries of a matrix matching a certain criteria, showing NULL for any entries that do not match. To see an example of removing any rows or columns that do not match a given criteria, see the Working with Subsections of Data - Extracting Data section in the LA_syntax_shortcuts page.
The flatten option was introduced in Maple 17.
For more information on Maple 17 changes, see Updates in Maple 17.
The inplace option was introduced in Maple 2018.
For more information on Maple 2018 changes, see Updates in Maple 2018.
Download Help Document
What kind of issue would you like to report? (Optional)