Up | Next | Prev | PrevTail | Tail |
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(
\(\langle \)fnc:function\(\rangle \), \(\langle \)lst:list\(\rangle \))
fnc
can be one of the following forms:
lst
;
=>
\(\langle \)rep\(\rangle \) where \(\langle \)var\(\rangle \) is a variable (a kernel
without subscript) and \(\langle \)rep\(\rangle \) is an expression that contains \(\langle \)var\(\rangle \). \(\langle \)rep\(\rangle \) is evaluated
for each element of LST
with the element substituted for \(\langle \)var\(\rangle \). \(\langle \)var\(\rangle \) 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 |