<?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>scanLines -- apply a function to each line of a file</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_scan__Pairs.html">next</a> | <a href="_scan__Keys.html">previous</a> | <a href="_scan__Pairs.html">forward</a> | <a href="_scan__Keys.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>scanLines -- apply a function to each line of a file</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>scanLines(f,fn)</tt></div> </dd></dl> </div> </li> <li><div class="single">Inputs:<ul><li><span><tt>f</tt></span></li> <li><span><tt>fn</tt>, the name of a file, or a list of names of files</span></li> </ul> </div> </li> <li><div class="single">Consequences:<ul><li>applies <tt>f</tt> to each line of the file(s)</li> </ul> </div> </li> <li><div class="single">Outputs:<ul><li><span>returns <a href="_null.html" title="the unique member of the empty class">null</a> unless the function uses <tt>break x</tt> with a non-null value for <tt>x</tt>, in which case scanning stops and <tt>x</tt> is returned immediately</span></li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div><p>The file is read and processed one block at a time, making this procedure potentially much better at conserving memory than <tt>scan(lines get fn,f)</tt> when the file is very large.</p> </div> </div> <div class="waystouse"><h2>Ways to use <tt>scanLines</tt> :</h2> <ul><li>scanLines(Function,List)</li> <li>scanLines(Function,String)</li> </ul> </div> </div> </body> </html>