Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 3950

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>&lt;- -- assignment with left side evaluated</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="__eq_eq.html">next</a> | <a href="__co_eq.html">previous</a> | <a href="__eq_eq.html">forward</a> | <a href="__co_eq.html">backward</a> | <a href="_operators.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<div><a href="index.html" title="">Macaulay2Doc</a> > <a href="___The_sp__Macaulay2_splanguage.html" title="">The Macaulay2 language</a> > <a href="_operators.html" title="">operators</a> > <a href="__lt-.html" title="assignment with left side evaluated">&lt;-</a></div>
<hr/>
<div><h1>&lt;- -- assignment with left side evaluated</h1>
<div class="single"><h2>Description</h2>
<div><div><h2>assignment to symbols</h2>
<ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>x &lt;- e</tt></div>
</dd></dl>
</div>
</li>
<li>Inputs:<ul><li><span><tt>x</tt>, <span>a <a href="___Symbol.html">symbol</a></span>,  (evaluated)</span></li>
<li><span><tt>e</tt>, <span>a <a href="___Thing.html">thing</a></span></span></li>
</ul>
</li>
<li>Consequences:<ul><li>assuming the value of <tt>x</tt> is a symbol, <tt>t</tt>, say, the value of <tt>e</tt> is assigned to <tt>t</tt> so that future references to the value of <tt>t</tt> yield <tt>e</tt>.</li>
</ul>
</li>
<li>Outputs:<ul><li><span>the value of the expression is the value of <tt>e</tt></span></li>
</ul>
</li>
</ul>
<table class="examples"><tr><td><pre>i1 : x = t

o1 = t

o1 : Symbol</pre>
</td></tr>
<tr><td><pre>i2 : x &lt;- 4

o2 = 4</pre>
</td></tr>
<tr><td><pre>i3 : x

o3 = t

o3 : Symbol</pre>
</td></tr>
<tr><td><pre>i4 : t

o4 = 4</pre>
</td></tr>
</table>
<p>Initially, the value of a symbol <tt>y</tt> is <tt>y</tt> itself, and then <tt>y = e</tt> and <tt>y &lt;- e</tt> do the same thing.</p>
<table class="examples"><tr><td><pre>i5 : y &lt;- 44

o5 = 44</pre>
</td></tr>
<tr><td><pre>i6 : y

o6 = 44</pre>
</td></tr>
</table>
<p>The code to the left of the arrow can be any expression whose value is a symbol.</p>
<table class="examples"><tr><td><pre>i7 : f = () -> symbol z

o7 = f

o7 : FunctionClosure</pre>
</td></tr>
<tr><td><pre>i8 : (f()) &lt;- 44

o8 = 44</pre>
</td></tr>
<tr><td><pre>i9 : z

o9 = 44</pre>
</td></tr>
</table>
</div>
<div><h2>installing new assignment methods</h2>
<ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>installMethod(symbol &lt;-, X, (x,e) -> ...)</tt></div>
</dd></dl>
</div>
</li>
<li>Inputs:<ul><li><span><tt>X</tt>, <span>a <a href="___Type.html">type</a></span></span></li>
<li><span><tt>(x,e) -> ...</tt>, <span>a <a href="___Function.html">function</a></span> of two arguments</span></li>
</ul>
</li>
<li>Consequences:<ul><li>the function <tt>(x,e) -> ...</tt> is installed as the method for assignment to objects of type <tt>X</tt>.  See the next subsection below for using it.</li>
</ul>
</li>
<li>Outputs:<ul><li><span>the value returned is the function provided</span></li>
</ul>
</li>
</ul>
<table class="examples"><tr><td><pre>i10 : installMethod(symbol &lt;-, String, peek)

o10 = peek

o10 : FunctionClosure</pre>
</td></tr>
</table>
</div>
<div><h2>using installed assignment methods</h2>
<ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>x &lt;- e</tt></div>
</dd></dl>
</div>
</li>
<li>Inputs:<ul><li><span><tt>x</tt>, an object of type X</span></li>
<li><span><tt>e</tt>, <span>a <a href="___Thing.html">thing</a></span></span></li>
</ul>
</li>
<li>Consequences:<ul><li>the previously installed method for assignment to objects of type <tt>X</tt> is called with arguments <tt>(x,e)</tt>, unless <tt>x</tt> is a symbol, in which case the internal assignment method applies, as described above.  If there is no method for <tt>X</tt>, then the ancestors of <tt>X</tt> are consulted, starting with the parent of <tt>X</tt> and ending with <a href="___Thing.html" title="the class of all things">Thing</a> (see <a href="_inheritance.html" title="">inheritance</a>).</li>
</ul>
</li>
<li>Outputs:<ul><li><span>the value of the expression is the value returned by the previously installed method</span></li>
</ul>
</li>
</ul>
<p>The following example used the method for assignment to strings installed above.</p>
<table class="examples"><tr><td><pre>i11 : "foo" &lt;- "bar"

o11 = ("foo", "bar")</pre>
</td></tr>
</table>
<p>As before, the left hand side is evaluated, and in this case, it can be any expression whose value is a string.</p>
<table class="examples"><tr><td><pre>i12 : "foo" | "foo" &lt;- "bar"

o12 = ("foofoo", "bar")</pre>
</td></tr>
</table>
</div>
<div><h2>assignment to an indexed variable</h2>
<ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>x &lt;- e</tt></div>
</dd></dl>
</div>
</li>
<li>Inputs:<ul><li><span><tt>x</tt>, <span>an <a href="___Indexed__Variable.html">indexed variable</a></span></span></li>
<li><span><tt>e</tt>, <span>a <a href="___Thing.html">thing</a></span></span></li>
</ul>
</li>
<li>Consequences:<ul><li>assuming the value of <tt>x</tt> is <span>an <a href="___Indexed__Variable.html">indexed variable</a></span>, the value of e is assigned to it, so that future references to <tt>value x</tt> or to <tt>s_i</tt>, if that's what the value of <tt>x</tt> is, yield <tt>e</tt>.  Moreover, the value of <tt>s</tt> is set to <tt>s</tt>.</li>
</ul>
</li>
<li>Outputs:<ul><li><span>the value of the expression is the value returned by the previously installed method</span></li>
</ul>
</li>
</ul>
<p>This assignment method is pre-installed.</p>
<table class="examples"><tr><td><pre>i13 : u = s_4

o13 = s
       4

o13 : IndexedVariable</pre>
</td></tr>
<tr><td><pre>i14 : s = 3

o14 = 3</pre>
</td></tr>
<tr><td><pre>i15 : u &lt;- 555
--warning: clearing value of symbol s to allow access to subscripted variables based on it

o15 = 555</pre>
</td></tr>
<tr><td><pre>i16 : s

o16 = s

o16 : IndexedVariableTable</pre>
</td></tr>
<tr><td><pre>i17 : s_4

o17 = 555</pre>
</td></tr>
<tr><td><pre>i18 : u

o18 = s
       4

o18 : IndexedVariable</pre>
</td></tr>
<tr><td><pre>i19 : value u

o19 = 555</pre>
</td></tr>
</table>
</div>
<div><h2>parallel assignment</h2>
<ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>x &lt;- e</tt></div>
</dd></dl>
</div>
</li>
<li>Inputs:<ul><li><span><tt>x</tt>, <span>a <a href="___Sequence.html">sequence</a></span></span></li>
<li><span><tt>e</tt>, <span>a <a href="___Sequence.html">sequence</a></span></span></li>
</ul>
</li>
<li>Consequences:<ul><li>assuming the values of <tt>x</tt> and of <tt>e</tt> are <span>a <a href="___Sequence.html">sequence</a></span>, with the same length, each member of <tt>e</tt> is assigned to the corresponding member of <tt>x</tt></li>
</ul>
</li>
<li>Outputs:<ul><li><span>the value of the expression is the value of <tt>e</tt></span></li>
</ul>
</li>
</ul>
<p>This assignment method is pre-installed.</p>
<table class="examples"><tr><td><pre>i20 : (symbol a, symbol b) &lt;- (3,4)

o20 = (3, 4)

o20 : Sequence</pre>
</td></tr>
<tr><td><pre>i21 : a

o21 = 3</pre>
</td></tr>
<tr><td><pre>i22 : (symbol r_1 .. symbol r_3) &lt;- (5,6,7)

o22 = (5, 6, 7)

o22 : Sequence</pre>
</td></tr>
<tr><td><pre>i23 : r_2

o23 = 6</pre>
</td></tr>
</table>
</div>
</div>
</div>
<div class="single"><h2>See also</h2>
<ul><li><span><a href="__eq.html" title="assignment">=</a> -- assignment</span></li>
<li><span><a href="__co_eq.html" title="assignment of method or new local variable">:=</a> -- assignment of method or new local variable</span></li>
<li><span><a href="__lt-.html" title="assignment with left side evaluated">IndexedVariable &lt;- Thing</a> -- assignment with left side evaluated</span></li>
</ul>
</div>
<div class="waystouse"><h2>Ways to use <tt>&lt;-</tt> :</h2>
<ul><li>IndexedVariable &lt;- Thing</li>
<li>Sequence &lt;- Thing</li>
</ul>
</div>
<div class="waystouse"><h2>For the programmer</h2>
<p>The object <a href="__lt-.html" title="assignment with left side evaluated">&lt;-</a> is <span>a <a href="___Keyword.html">keyword</a></span>.</p>
</div>
</div>
</body>
</html>