Artifact 6eef7a6e8c6f222852a3e7f68ded66d651d053c8e3f48117b9cf639811380f47:
- Executable file
r37/lisp/csl/html/r37_0227.html
— part of check-in
[f2fda60abd]
at
2011-09-02 18:13:33
on branch master
— Some historical releases purely for archival purposes
git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1375 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 2430) [annotate] [blame] [check-ins using] [more...]
<A NAME=WHERE> <TITLE>WHERE</TITLE></A> <b><a href=r37_idx.html>INDEX</a></b><p><p> <B>WHERE</B> _ _ _ _ _ _ _ _ _ _ _ _ <B>operator</B><P> <P> <P> <P> The <em>where</em> operator provides an infix notation for one-time substitutions for kernels in expressions. <P> <H3> syntax: </H3> <P> <P> <expression> <em>where</em> <kernel> <em>=</em><expression> {,<kernel> <em>=</em><expression>}* <P> <P> <P> <expression> can be any REDUCE scalar expression, <kernel> must be a <A HREF=r37_0002.html>kernel</A>. Alternatively a <A HREF=r37_0060.html>rule</A> or a <em>rule list</em> can be a member of the right-hand part of a <em>where</em> expression. <P> <P> <P> <H3> examples: </H3> <P><PRE><TT> x**2 + 17*x*y + 4*y**2 where x=1,y=2; 51 for i := 1:5 collect x**i*q where q= for j := 1:i product j; 2 3 4 5 {X,2*X ,6*X ,24*X ,120*X } x**2 + y + z where z=y**3,y=3; 2 3 X + Y + 3 </TT></PRE><P>Substitution inside a <em>where</em> expression has no effect upon the values of the kernels outside the expression. The <em>where</em> operator has the lowest precedence of all the infix operators, which are lower than prefix operators, so that the substitutions apply to the entire expression preceding the <em>where</em> operator. However, <em>where</em> is applied before command keywords such as <em>then</em>, <em>repeat</em>, or <em>do</em>. <P> <P> A <A HREF=r37_0060.html>rule</A> or a <em>rule set</em> in the right-hand part of the <em>where</em> expression act as if the rules were activated by <A HREF=r37_0199.html>let</A> immediately before the evaluation of the expression and deactivated by <A HREF=r37_0190.html>clearrules</A> immediately afterwards. <P> <P> <em>where</em>gives you a natural notation for auxiliary variables in expressions. As the second example shows, the substitute expression can be a command to be evaluated. The substitute assignments are made in parallel, rather than sequentially, as the last example shows. The expression resulting from the first round of substitutions is not reexamined to see if any further such substitutions can be made. <em>where</em> can also be used to define auxiliary variables in <A HREF=r37_0055.html>procedure</A> definitions. <P> <P> <P>