select - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Operations : Sets and lists : select

select

selection from an expression

remove

removal from an expression

selectremove

selection or removal from an expression

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

Compatibility

Calling Sequence

select(f, e, b1, ..., bn)

select[flatten](f, e, b1, ..., bn)

remove(f, e, b1, ..., bn)

remove[flatten](f, e, b1, ..., bn)

selectremove(f, e, b1, ..., bn)

selectremove[flatten](f, e, b1, ..., bn)

Parameters

f

-

Boolean-valued procedure

e

-

any expression

b1, ..., bn

-

(optional) extra arguments

Description

• 

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, Matrix, or Vector, the select[flatten] form can be used.  This will cause 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).

• 

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  cremovehas,e,x. It is more efficient, however, to use v,cselectremovehas,e,x. Do not try to compute cev. Because of the way Maple simplifies expressions, factors do not cancel out in general. See the last example below.

Thread Safety

• 

The select, remove and selectremove commands are thread-safe as of Maple 15.

• 

For more information on thread safety, see index/threadsafe.

Examples

integers`$`10..20

integers:=10,11,12,13,14,15,16,17,18,19,20

(1)

selectisprime,integers

11,13,17,19

(2)

removeisprime,integers

10,12,14,15,16,18,20

(3)

selectremoveisprime,integers

11,13,17,19,10,12,14,15,16,18,20

(4)

f2ⅇaxsinxlny

f:=2ⅇaxsinxlny

(5)

selecthas,f,x

ⅇaxsinx

(6)

removehas,f,x

2lny

(7)

selectremovehas,f,x

ⅇaxsinx,2lny

(8)

fyx

f:=yx

(9)

selectremovehas,f,x

undefined,y

(10)

findetsf

f:=x,y,yx

(11)

selecttype,f,'name'

x,y

(12)

removetype,f,'name'

yx

(13)

selectremovetype,f,'name'

x,y,yx

(14)

f2lnxy+1

f:=2lnxy+1

(15)

cremovehas,f,x

c:=2y+2

(16)

fc

2lnxy+12y+2

(17)

selecthas,f,x

lnx

(18)

removex&rarr;2<x&comma;1&comma;2&comma;3

12NULL

(19)

remove&lsqb;flatten&rsqb;x&rarr;2<x&comma;1&comma;2&comma;3

12

(20)

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.

selectx&rarr;2<x&comma;1&verbar;2&comma;3&verbar;4

NULLNULL34

(21)

select&lsqb;flatten&rsqb;x&rarr;2<x&comma;1&verbar;2&comma;3&verbar;4

34

(22)

Compatibility

• 

The flatten option was introduced in Maple 17.

• 

For more information on Maple 17 changes, see Updates in Maple 17.

See Also

member

membertype

selectfun

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam