SELECT INDEX

SELECT _ _ _ _ _ _ _ _ _ _ _ _ operator

The select operator extracts from a list or from the arguments of an n--ary operator elements corresponding to a boolean predicate. The predicate pattern can be a unary procedure, an operator or an algebraic expression with one free variable.

syntax:

select(<function>,<object>)

<object> is a list.

<function> is the name of an operator for a single argument: the operator is evaluated once with each element of <object> as its single argument,

or an algebraic expression with exactly one free variable, that is a variable preceded by the tilde symbol: the expression is evaluated for each element of <object> where the element is substituted for the free variable,

or a replacement rule of the form

syntax:

var=> rep

where <var> is a variable (a <kernel> without subscript) and <rep> is an expression which contains <var>. Here rep is evaluated for each element of <object> where the element is substituted for var. var may be optionally preceded by a tilde.

The rule form for <function> is needed when more than one free variable occurs. The evaluation result of <function> is interpreted as boolean value corresponding to the conventions of REDUCE. The result value is built with the leading operator of the input expression.

examples:


  select( ~w>0 , {1,-1,2,-3,3}) 

  {1,2,3} 


  q:=(part((x+y)^5,0):=list)

  select(evenp deg(~w,y),q);

    5      3   2       4
  {x  ,10*x  *y  ,5*x*y  }


  select(evenp deg(~w,x),2x^2+3x^3+4x^4);


    2   4
  2x +4x