SELECT Operator
Date: 2020-10-07 18:10:00

Up | Next | Prev | PrevTail | Tail

### 7.15 SELECT Operator

The SELECT operator extracts from a list, or from the arguments of an n–ary operator, elements corresponding to a boolean predicate. It is used with the syntax:

SELECT(⟨FNC:function⟩,⟨LST:list⟩)

FNC can be one of the following forms:

1. the name of an operator with a single argument: the operator is evaluated once on each element of LST;
2. an algebraic expression with exactly one free variable, i.e. a variable preceded by the tilde symbol. The expression is evaluated for each element of ⟨LST⟩, with the element substituted for the free variable;
3. a replacement rule of the form ⟨var⟩ => ⟨rep⟩ where ⟨var⟩ is a variable (a kernel without subscript) and ⟨rep⟩ is an expression that contains ⟨var⟩. ⟨rep⟩ is evaluated for each element of LST with the element substituted for ⟨var⟩. ⟨var⟩ may be optionally preceded by a tilde.

The rule form for FNC is needed when more than one free variable occurs.

The result of evaluating FNC is interpreted as a boolean value corresponding to the conventions of REDUCE. These values are composed with the leading operator of the input expression.

Examples:

select( ~w>0 , {1,-1,2,-3,3}) -> {1,2,3}
select(evenp deg(~w,y),part((x+y)^5,0):=list)
-> {X^5 ,10*X^3*Y^2 ,5*X*Y^4}
select(evenp deg(~w,x),2x^2+3x^3+4x^4) -> 4X^4 + 2X^2

Up | Next | Prev | PrevTail | Front