Sophie

Sophie

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

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>printing to the screen</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_reading_spfiles.html">next</a> | <a href="_method.html">previous</a> | <a href="_reading_spfiles.html">forward</a> | <a href="_making_spa_spnew_spmethod_spfunction.html">backward</a> | <a href="___The_sp__Macaulay2_splanguage.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="_printing_spto_spthe_spscreen.html" title="">printing to the screen</a></div>
<hr/>
<div><h1>printing to the screen</h1>
<div>Use the operator <a href="__lt_lt.html" title="a binary operator (file output, ...)">&lt;&lt;</a> to print something to the screen.<table class="examples"><tr><td><pre>i1 : &lt;&lt; 2^100
1267650600228229401496703205376
o1 = stdio

o1 : File</pre>
</td></tr>
</table>
Notice that the value returned is the standard input output file <a href="_stdio.html" title="the standard input output file">stdio</a>.  We can also use <a href="__lt_lt.html" title="a binary operator (file output, ...)">&lt;&lt;</a> as a binary operator to print explicitly to this file, and the output will appear on the screen.<table class="examples"><tr><td><pre>i2 : stdio &lt;&lt; 2^100
1267650600228229401496703205376
o2 = stdio

o2 : File</pre>
</td></tr>
</table>
The associativity of the operator <a href="__lt_lt.html" title="a binary operator (file output, ...)">&lt;&lt;</a> during parsing is arranged so that the following code will work in a useful way.<table class="examples"><tr><td><pre>i3 : &lt;&lt; "The answer is " &lt;&lt; 2^100 &lt;&lt; ".";
The answer is 1267650600228229401496703205376.</pre>
</td></tr>
</table>
Printing works fine with nets, too.<table class="examples"><tr><td><pre>i4 : &lt;&lt; "The answer is " &lt;&lt; "aaa"||"bb"||"c" &lt;&lt; ".";
The answer is aaa.
              bb
              c</pre>
</td></tr>
</table>
In the presence of nets, which are used whenever you print something that is formatted two-dimensionally, the only correct way to terminate a line is with <a href="_endl.html" title="end an output line">endl</a>, even though a string called <a href="_newline.html" title="the new line character sequence">newline</a> is available to you.<table class="examples"><tr><td><pre>i5 : R = ZZ[x,y];</pre>
</td></tr>
<tr><td><pre>i6 : f = (x+y+1)^2; g = (x-y+1)^2

      2           2
o7 = x  - 2x*y + y  + 2x - 2y + 1

o7 : R</pre>
</td></tr>
<tr><td><pre>i8 : &lt;&lt; "f = " &lt;&lt; f &lt;&lt; endl &lt;&lt; "g = " &lt;&lt; g &lt;&lt; endl;
     2           2
f = x  + 2x*y + y  + 2x + 2y + 1
     2           2
g = x  - 2x*y + y  + 2x - 2y + 1</pre>
</td></tr>
</table>
Output is saved in a buffer until the end of the line is encountered.  If nets are not involved, you may use <a href="_flush.html" title="flush output to file">flush</a> to force the output to appear on the screen before the end of the line is encountered.  This may be useful in displaying some tiny indication of computational progress to the user.<table class="examples"><tr><td><pre>i9 : scan(0 .. 20, i -> &lt;&lt; "." &lt;&lt; flush)
.....................</pre>
</td></tr>
</table>
<p/>
If long lines get displayed too slowly, such as in emacs, then the user may choose to put a line such as <tt>truncateOutput 100</tt> into an <a href="_initialization_spfile.html" title="">initialization file</a>.  Time is still spent creating the wide output that is eventually truncated.<table class="examples"><tr><td><pre>i10 : truncateOutput 50</pre>
</td></tr>
<tr><td><pre>i11 : 41!

o11 = 33452526613163807108170062053440751665152000000000</pre>
</td></tr>
<tr><td><pre>i12 : 42!

o12 = 1405006117752879898543142606244511569936384000 ...</pre>
</td></tr>
<tr><td><pre>i13 : 43!

o13 = 6041526306337383563735513206851399750726451200 ...</pre>
</td></tr>
<tr><td><pre>i14 : truncateOutput infinity

o14 = identity

o14 : CompiledFunction</pre>
</td></tr>
<tr><td><pre>i15 : 43!

o15 = 60415263063373835637355132068513997507264512000000000</pre>
</td></tr>
</table>
</div>
</div>
</body>
</html>