File r37/lisp/csl/html/r37_0163.html artifact a7e3e0d93a part of check-in trunk



<A NAME=MAP>

<TITLE>MAP</TITLE></A>
<b><a href=r37_idx.html>INDEX</a></b><p><p>



<B>MAP</B> _ _ _  _ _ _  _ _ _  _ _ _ <B>operator</B><P>
<P>
 
 <P>
<P>
The <em>map</em> operator applies a uniform evaluation pattern 
to all members of a composite structure: a 
<A HREF=r37_0345.html>matrix</A>, 
a 
<A HREF=r37_0053.html>list</A> or the arguments of an 
<A HREF=r37_0211.html>operator</A> expression. 
The evaluation pattern can be a 
unary procedure, an operator, or an algebraic expression with 
one free variable. 
 <P> <H3> 
syntax: </H3>
<P>
<P>
<em>map</em>(&lt;function&gt;,&lt;object&gt;) 
<P>
<P>
<P>
&lt;object&gt; is a list, a matrix or an operator expression. 
<P>
<P>
&lt;function&gt; is 
the name of an operator for a single argument: the operator 
is evaluated once with each element of &lt;object&gt; as its single argument, 
<P>
<P>
or an algebraic expression with exactly one 
<A HREF=r37_0061.html>free variable</A>, that is 
a variable preceded by the tilde symbol: the expression 
 is evaluated for each element of &lt;object&gt; where the element is 
 substituted for the free variable, 
<P>
<P>
or a replacement 
<A HREF=r37_0060.html>rule</A> of the form 
 <P> <H3> 
syntax: </H3>
<P>
<P>
<em>var</em>=&gt; <em>rep</em> 
<P>
<P>
<P>
where &lt;var&gt; is a variable (a &lt;kernel&gt; without subscript) 
 and &lt;rep&gt; is an expression which contains &lt;var&gt;. 
 Here <em>rep</em> is evaluated for each element of &lt;object&gt; where 
 the element is substituted for <em>var</em>. <em>var</em> may be 
 optionally preceded by a tilde. 
<P>
<P>
The rule form for &lt;function&gt; is needed when more than 
one free variable occurs. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<P><PRE><TT>
map(abs,{1,-2,a,-a}); 

  1,2,abs(a),abs(a) 


map(int(~w,x), mat((x^2,x^5),(x^4,x^5))); 


          [  3     6 ]
          [ x     x  ]
          [----  ----]
          [ 3     6  ]
          [          ]
          [  5     6 ]
          [ x     x  ]
          [----  ----]
  	[ 5     6  ]


map(~w*6, x^2/3 = y^3/2 -1); 

     2     3
  2*x =3*(y -2)

</TT></PRE><P>You can use <em>map</em> in nested expressions. It is not allowed 
to 
apply <em>map</em> for a non-composed object, e.g. an identifier or a number. 
<P>
<P>
<P>


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]