Select, Remove - Maple Help

DataSeries/select

selection from a DataSeries

DataSeries/remove

removal from a DataSeries

DataSeries/selectremove

selection and removal from a DataSeries

 Calling Sequence select(f, DS, b1, ..., bn) select[inplace](f, DS, b1, ..., bn) remove(f, DS, b1, ..., bn) remove[inplace](f, DS, b1, ..., bn) selectremove(f, DS, b1, ..., bn) selectremove[inplace](f, DS, b1, ..., bn)

Parameters

 f - Boolean-valued procedure DS - a DataSeries object b1, ..., bn - (optional) extra arguments for f

Description

 • When called on a DataSeries object, the select command returns a DataSeries object consisting of those entries that satisfy the given criterion.
 • When called on a DataSeries object, the remove command returns a DataSeries object consisting of those entries that do not satisfy the given criterion.
 • When called on a DataSeries object, the selectremove command returns a sequence of two DataSeries objects, the first consisting of those entries that satisfy the given criterion and the second consisting of those entries that don't satisfy the given criterion.
 • The commands can also be called on other types of arguments. This behavior is described on the main help page for select.
 • The criterion used for deciding whether an entry $x$ of the DataSeries is included in the result is to call $f\left(x,\mathrm{b1},\mathrm{...},\mathrm{bn}\right)$. This should return true or false (or FAIL, which is interpreted in the same way as false). If you call select, then the returned DataSeries will contain $x$ if and only if the value returned is true. If you call remove, then the returned DataSeries will contain $x$ if and only if the value returned is false (or FAIL).
 • Any entry that is included in the result will have the same label that it has in DS.
 • If you call select[inplace] or remove[inplace], the command will modify the DataSeries object DS and return it. The calling sequences with no index on the command name will return a new DataSeries object and leave DS unchanged. If you call selectremove[inplace], then the command will modify DS to be the first DataSeries returned, and the second DataSeries will be a new DataSeries object.
 • You can do similar things with DataSeries indexing using a Boolean DataSeries. See the examples below.

Examples

We split $\mathrm{ds}$, below, into prime and non-prime entries in various ways, using the isprime command as the testing criterion.

 > $\mathrm{ds}≔\mathrm{DataSeries}\left(\left[5,6,7,8,9\right],\mathrm{labels}=\left[a,b,c,d,e\right]\right)$
 ${\mathrm{ds}}{≔}\left[\begin{array}{cc}{a}& {5}\\ {b}& {6}\\ {c}& {7}\\ {d}& {8}\\ {e}& {9}\end{array}\right]$ (1)
 > $\mathrm{select}\left(\mathrm{isprime},\mathrm{ds}\right)$
 $\left[\begin{array}{cc}{a}& {5}\\ {c}& {7}\end{array}\right]$ (2)
 > $\mathrm{remove}\left(\mathrm{isprime},\mathrm{ds}\right)$
 $\left[\begin{array}{cc}{b}& {6}\\ {d}& {8}\\ {e}& {9}\end{array}\right]$ (3)
 > $\mathrm{selectremove}\left(\mathrm{isprime},\mathrm{ds}\right)$
 $\left[\begin{array}{cc}{a}& {5}\\ {c}& {7}\end{array}\right]{,}\left[\begin{array}{cc}{b}& {6}\\ {d}& {8}\\ {e}& {9}\end{array}\right]$ (4)

The same results can be obtained using indexing with a Boolean DataSeries.

 > ${\mathrm{ds}}_{{\mathrm{~}}_{\mathrm{isprime}}\left(\mathrm{ds}\right)}$
 $\left[\begin{array}{cc}{a}& {5}\\ {c}& {7}\end{array}\right]$ (5)
 > ${\mathrm{ds}}_{\mathbf{not}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{~}}_{\mathrm{isprime}}\left(\mathrm{ds}\right)}$
 $\left[\begin{array}{cc}{b}& {6}\\ {d}& {8}\\ {e}& {9}\end{array}\right]$ (6)

If we want to select the entries of a particular type, then we can use the optional third argument to select.

 > $\mathrm{select}\left(\mathrm{type},\mathrm{ds},\mathrm{even}\right)$
 $\left[\begin{array}{cc}{b}& {6}\\ {d}& {8}\end{array}\right]$ (7)

The original DataSeries, $\mathrm{ds}$, is unchanged, because we used the commands without the inplace index.

 > $\mathrm{ds}$
 $\left[\begin{array}{cc}{a}& {5}\\ {b}& {6}\\ {c}& {7}\\ {d}& {8}\\ {e}& {9}\end{array}\right]$ (8)

If we call select with the inplace index, then $\mathrm{ds}$ is modified in-place.

 > ${\mathrm{select}}_{\mathrm{inplace}}\left(\mathrm{isprime},\mathrm{ds}\right)$
 $\left[\begin{array}{cc}{a}& {5}\\ {c}& {7}\end{array}\right]$ (9)
 > $\mathrm{ds}$
 $\left[\begin{array}{cc}{a}& {5}\\ {c}& {7}\end{array}\right]$ (10)

Compatibility

 • The DataSeries/select, DataSeries/remove and DataSeries/selectremove commands were introduced in Maple 2019.