Sophie

Sophie

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

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>return -- return from a function</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_return__Code.html">next</a> | <a href="___Result.html">previous</a> | <a href="_return__Code.html">forward</a> | <a href="___Result.html">backward</a> | up | <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>
<hr/>
<div><h1>return -- return from a function</h1>
<div class="single"><h2>Synopsis</h2>
<ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>return x</tt></div>
</dd></dl>
</div>
</li>
<li><div class="single">Inputs:<ul><li><span><tt>x</tt>, If <tt>x</tt> is omitted, then <a href="_null.html" title="the unique member of the empty class">null</a> is used.</span></li>
</ul>
</div>
</li>
<li><div class="single">Consequences:<ul><li>Returns <tt>x</tt> as the value of the function currently being evaluated.</li>
<li>Alternatively, as a debugger command, returns <tt>x</tt> as the value of the current expression and stops execution at the next possible point, entering the debugger again.</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="single"><h2>Description</h2>
<div><table class="examples"><tr><td><pre>i1 : f = x -> (
          if x == 3 then return;
          if x > 3 then return x^2;
          5);</pre>
</td></tr>
<tr><td><pre>i2 : f 2

o2 = 5</pre>
</td></tr>
<tr><td><pre>i3 : f 3</pre>
</td></tr>
<tr><td><pre>i4 : f 4

o4 = 16</pre>
</td></tr>
</table>
<p>Here is an example of the use of <a href="_return.html" title="return from a function">return</a> as a debugger command.</p>
<table class="examples"><tr><td><pre>i5 : load "Macaulay2Doc/demo1.m2"</pre>
</td></tr>
<tr><td><pre>i6 : code g

o6 = /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo1.m2:11:7-14:8: --source code:
     g = y -> (
          c := f(y-1);
          d := f(y-2);
          c+d)</pre>
</td></tr>
<tr><td><pre>i7 : g 2
/builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo1.m2:8:12:(3):[2]: error: division by zero
/builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo1.m2:8:12:(3):[2]: --entering debugger (type help to see debugger commands)
/builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo1.m2:8:11-8:13: --source code:
     b := 1/x;</pre>
</td></tr>
<tr><td><pre>ii8 : code f

oo8 = /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo1.m2:6:8-9:8: --source code:
      f := x -> (
           a := "hi there";
           b := 1/x;
           b+1)</pre>
</td></tr>
<tr><td><pre>ii9 : return 1/11
/builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo1.m2:9:7:(3):[2]: --stepping limit reached
/builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo1.m2:9:7:(3):[2]: --entering debugger (type help to see debugger commands)
/builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo1.m2:9:6-9:8: --source code:
     b+1)</pre>
</td></tr>
<tr><td><pre>ii10 : continue

      34
o10 = --
      11

o10 : QQ</pre>
</td></tr>
</table>
</div>
</div>
<div class="single"><h2>See also</h2>
<ul><li><span><a href="_break.html" title="break from a loop">break</a> -- break from a loop</span></li>
</ul>
</div>
<div class="waystouse"><h2>For the programmer</h2>
<p>The object <a href="_return.html" title="return from a function">return</a> is <span>a <a href="___Keyword.html">keyword</a></span>.</p>
</div>
</div>
</body>
</html>