/usr/share/doc/racket/teachpack/2htdpbatch-io.html is in racket-doc 6.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>2.1 Batch Input/Output: "batch-io.rkt"</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="io.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">►</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x"><span style="font-style: italic">How to Design Programs</span> Teachpacks</a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="htdp.html" class="tocviewlink" data-pltdoc="x">Ht<span class="mywbr"> </span>DP Teachpacks</a></td></tr><tr><td align="right">2 </td><td><a href="2htdp2htdp.html" class="tocviewselflink" data-pltdoc="x">Ht<span class="mywbr"> </span>DP/<span class="mywbr"> </span>2e Teachpacks</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_1");">▼</a></td><td>2 </td><td><a href="2htdp2htdp.html" class="tocviewlink" data-pltdoc="x">Ht<span class="mywbr"> </span>DP/<span class="mywbr"> </span>2e Teachpacks</a></td></tr></table><div class="tocviewsublist" style="display: block;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">2.1 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Batch Input/<span class="mywbr"> </span>Output:<span class="mywbr"> </span> <span class="stt">"batch-<wbr></wbr>io.rkt"</span><a name="(idx._(gentag._20._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></a></td></tr><tr><td align="right">2.2 </td><td><a href="2htdpimage-guide.html" class="tocviewlink" data-pltdoc="x">Image Guide</a></td></tr><tr><td align="right">2.3 </td><td><a href="2htdpimage.html" class="tocviewlink" data-pltdoc="x">Images:<span class="mywbr"> </span> <span class="stt">"image.rkt"</span><a name="(idx._(gentag._21._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></a></td></tr><tr><td align="right">2.4 </td><td><a href="2htdpuniverse.html" class="tocviewlink" data-pltdoc="x">Worlds and the Universe:<span class="mywbr"> </span> <span class="stt">"universe.rkt"</span><a name="(idx._(gentag._22._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></a></td></tr><tr><td align="right">2.5 </td><td><a href="2htdpPlanet_Cute_Images.html" class="tocviewlink" data-pltdoc="x">Planet Cute Images</a></td></tr><tr><td align="right">2.6 </td><td><a href="2htdphtdp-port.html" class="tocviewlink" data-pltdoc="x">Porting World Programs to Universe</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_2");">►</a></td><td>2.1 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Batch Input/<span class="mywbr"> </span>Output:<span class="mywbr"> </span> <span class="stt">"batch-<wbr></wbr>io.rkt"</span><a name="(idx._(gentag._20._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_2"><table cellspacing="0" cellpadding="0"><tr><td align="right">2.1.1 </td><td><a href="#%28part._.I.O_.Functions%29" class="tocviewlink" data-pltdoc="x">IO Functions</a></td></tr><tr><td align="right">2.1.2 </td><td><a href="#%28part._.Web_.Functions%29" class="tocviewlink" data-pltdoc="x">Web Functions</a></td></tr><tr><td align="right">2.1.3 </td><td><a href="#%28part._.Testing%29" class="tocviewlink" data-pltdoc="x">Testing</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber">2.1.1<tt> </tt></span><a href="#%28part._.I.O_.Functions%29" class="tocsubseclink" data-pltdoc="x">IO Functions</a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-file%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>file</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-1strings%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>1strings</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-lines%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>lines</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>words</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words%2Fline%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>words/<span class="mywbr"> </span>line</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words-and-numbers%2Fline%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>words-<wbr></wbr>and-<wbr></wbr>numbers/<span class="mywbr"> </span>line</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-csv-file%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>csv-<wbr></wbr>file</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-csv-file%2Frows%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>csv-<wbr></wbr>file/<span class="mywbr"> </span>rows</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-xexpr%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>xexpr</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-plain-xexpr%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>plain-<wbr></wbr>xexpr</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._write-file%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">write-<wbr></wbr>file</span></span></a></td></tr><tr><td><span class="tocsublinknumber">2.1.2<tt> </tt></span><a href="#%28part._.Web_.Functions%29" class="tocsubseclink" data-pltdoc="x">Web Functions</a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-xexpr%2Fweb%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>xexpr/<span class="mywbr"> </span>web</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-plain-xexpr%2Fweb%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">read-<wbr></wbr>plain-<wbr></wbr>xexpr/<span class="mywbr"> </span>web</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._url-exists~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">url-<wbr></wbr>exists?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">xexpr?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr-as-string%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">xexpr-<wbr></wbr>as-<wbr></wbr>string</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._url-html-neighbors%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">url-<wbr></wbr>html-<wbr></wbr>neighbors</span></span></a></td></tr><tr><td><span class="tocsublinknumber">2.1.3<tt> </tt></span><a href="#%28part._.Testing%29" class="tocsubseclink" data-pltdoc="x">Testing</a></td></tr><tr><td><a href="#%28form._%28%28lib._2htdp%2Fbatch-io..rkt%29._simulate-file%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">simulate-<wbr></wbr>file</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="2htdp2htdp.html" title="backward to "2 HtDP/2e Teachpacks"" data-pltdoc="x">← prev</a> <a href="2htdp2htdp.html" title="up to "2 HtDP/2e Teachpacks"" data-pltdoc="x">up</a> <a href="2htdpimage-guide.html" title="forward to "2.2 Image Guide"" data-pltdoc="x">next →</a></span> </div><h4 x-source-module="(lib "teachpack/teachpack.scrbl")" x-part-tag=""batch-io"">2.1<tt> </tt><a name="(part._batch-io)"></a><a name="(mod-path._2htdp/batch-io)"></a>Batch Input/Output: <span class="stt">"batch-io.rkt"</span><a name="(idx._(gentag._20._(lib._teachpack/teachpack..scrbl)._2htdp))"></a></h4><div class="SAuthorListBox"><span class="SAuthorList"><p class="author">Matthias Felleisen</p></span></div><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=htdp-langs&rel=beginner.html%23%2528form._%2528%2528lib._lang%252Fhtdp-beginner..rkt%2529._require%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">2htdp/batch-io</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">htdp-lib</span></span></td></tr></table></p><p>The batch-io teachpack introduces several functions and a form for reading
content from files and one function for writing to a file.</p><h5 x-source-module="(lib "teachpack/teachpack.scrbl")" x-part-tag=""IO_Functions"">2.1.1<tt> </tt><a name="(part._.I.O_.Functions)"></a>IO Functions</h5><p><div class="SIntrapara">All functions that read a file consume the name of a file and possibly
additional arguments. They assume that the specified file exists in the
same folder as the program; if not they signal an error:
</div><div class="SIntrapara"><ul><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-file))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-file%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-file</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-in</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._and%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._file-exists%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">file-exists?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">reads the standard input device (until closed) or the content of file
<span class="RktVar">f</span> and produces it as a string, including newlines.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-file%29%29" class="RktValLink" data-pltdoc="x">read-file</a></span><span class="hspace"> </span><span class="RktVal">"data.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"hello world \n good bye \n\ni, for 1, am done "</span></p></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">assuming the file named <span class="RktVal">"data.txt"</span> has this shape:
</div><div class="SIntrapara"><blockquote class="SubFlow"><table cellspacing="0" cellpadding="0" class="FileBox"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">hello world </span></p></td></tr><tr><td><p><span class="stt"></span><span class="hspace"> </span><span class="stt">good bye </span></p></td></tr><tr><td><p><span class="stt"></span><span class="hspace"> </span></p></td></tr><tr><td><p><span class="stt">i, for 1, am done </span></p></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Note how the leading space in the second line translates into the space
between the newline indicator and the word <span class="RktVal">"good"</span> in the result.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-1strings))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-1strings%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-1strings</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym">1string?</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-in</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._and%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._file-exists%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">file-exists?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">reads the standard input device (until closed) or the content of file
<span class="RktVar">f</span> and produces it as a list of one-char strings, one per character.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-1strings%29%29" class="RktValLink" data-pltdoc="x">read-1strings</a></span><span class="hspace"> </span><span class="RktVal">"data.txt"</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktRes">'("h"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"e"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"l"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"l"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"o"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">" "</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"w"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"o"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"r"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"l"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"d"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">" "</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"\n"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">" "</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"g"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"o"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"o"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"d"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">" "</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"b"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"y"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"e"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">" "</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"\n"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"\n"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"i"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">","</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">" "</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"f"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"o"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"r"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">" "</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"1"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">","</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">" "</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"a"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"m"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">" "</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"d"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"o"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"n"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">"e"</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">" ")</span></p></td></tr></table></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">Note how this function reproduces all parts of the file faithfully,
including spaces and newlines.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-lines))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-lines%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-lines</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-in</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._and%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._file-exists%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">file-exists?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">reads the standard input device (until closed) or the content of file
<span class="RktVar">f</span> and produces it as a list of strings, one per line.
</div><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-lines%29%29" class="RktValLink" data-pltdoc="x">read-lines</a></span><span class="hspace"> </span><span class="RktVal">"data.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'("hello world " " good bye " "" "i, for 1, am done ")</span></p></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">when <span class="RktVal">"data.txt"</span> is the name of the same file as in the preceding
item. And again, the leading space of the second line shows up in the
second string in the list.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-words))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-words</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-in</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._and%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._file-exists%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">file-exists?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">reads the standard input device (until closed) or the content of file
<span class="RktVar">f</span> and produces it as a list of strings, one per white-space separated token in the file.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words%29%29" class="RktValLink" data-pltdoc="x">read-words</a></span><span class="hspace"> </span><span class="RktVal">"data.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'("hello" "world" "good" "bye" "i," "for" "1," "am" "done")</span></p></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">This time, however, the extra leading space of the second line of
<span class="RktVal">"data.txt"</span> has disappeared in the result. The space is considered
a part of the separator that surrounds the word <span class="RktVal">"good"</span>.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-words/line))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words%2Fline%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-words/line</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-in</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._and%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._file-exists%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">file-exists?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">reads the standard input device (until closed) or the content of file
<span class="RktVar">f</span> and produces it as a list of lists, one per line; each line is represented as a list of strings.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words%2Fline%29%29" class="RktValLink" data-pltdoc="x">read-words/line</a></span><span class="hspace"> </span><span class="RktVal">"data.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(("hello" "world") ("good" "bye") () ("i," "for" "1," "am" "done"))</span></p></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">The results is similar to the one that <span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words%29%29" class="RktValLink" data-pltdoc="x">read-words</a></span> produces,
except that the organization of the file into lines is preserved.
In particular, the empty third line is represented as an empty list of words.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-words-and-numbers/line))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words-and-numbers%2Fline%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-words-and-numbers/line</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._or%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">or</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._number%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">number?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-in</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._and%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._file-exists%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">file-exists?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">reads the standard input device (until closed) or the content of file
<span class="RktVar">f</span> and produces it as a list of lists, one per line; each line is represented as a list of strings and numbers.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words-and-numbers%2Fline%29%29" class="RktValLink" data-pltdoc="x">read-words-and-numbers/line</a></span><span class="hspace"> </span><span class="RktVal">"data.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(("hello" "world") ("good" "bye") () ("i," "for" "1," "am" "done"))</span></p></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">The results is like the one that <span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-words%2Fline%29%29" class="RktValLink" data-pltdoc="x">read-words/line</a></span> produces,
except strings that can be parsed as numbers are represented as numbers.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-csv-file))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-csv-file%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-csv-file</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-in</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._and%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._file-exists%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">file-exists?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">reads the standard input device (until closed) or the content of file
<span class="RktVar">f</span> and produces it as a list of lists of comma-separated values.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-csv-file%29%29" class="RktValLink" data-pltdoc="x">read-csv-file</a></span><span class="hspace"> </span><span class="RktVal">"data.csv"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(("hello" "world") ("good" "bye") ("i" "am" "done"))</span></p></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">where the file named <span class="RktVal">"data.csv"</span> has this shape:
</div><div class="SIntrapara"><blockquote class="SubFlow"><table cellspacing="0" cellpadding="0" class="FileBox"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">hello, world </span></p></td></tr><tr><td><p><span class="stt"></span><span class="hspace"> </span><span class="stt">good, bye </span></p></td></tr><tr><td><p><span class="stt">i, am, done </span></p></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">It is important to understand that the rows don’t have to have the same
length. Here the third line of the file turns into a row of three
elements.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-csv-file/rows))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-csv-file%2Frows%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-csv-file/rows</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span><span class="RktVar">s</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym">X?</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-in</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._and%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._file-exists%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">file-exists?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">X?</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">reads the standard input device (until closed) or the content of file
<span class="RktVar">f</span> and produces it as reads the content of file <span class="RktSym">f</span> and
produces it as list of rows, each constructed via <span class="RktVar">s</span>.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-csv-file%2Frows%29%29" class="RktValLink" data-pltdoc="x">read-csv-file/rows</a></span><span class="hspace"> </span><span class="RktVal">"data.csv"</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(("hello" "world") ("good" "bye") ("i" "am" "done"))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-csv-file%2Frows%29%29" class="RktValLink" data-pltdoc="x">read-csv-file/rows</a></span><span class="hspace"> </span><span class="RktVal">"data.csv"</span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._length%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">length</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(2 2 3)</span></p></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">The first example shows how <span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-csv-file%29%29" class="RktValLink" data-pltdoc="x">read-csv-file</a></span> is just a short form
for <span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-csv-file%2Frows%29%29" class="RktValLink" data-pltdoc="x">read-csv-file/rows</a></span>; the second one simply counts the
number of separated tokens and the result is just a list of numbers.
In many cases, the function argument is used to construct a structure from
a row.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-xexpr))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-xexpr%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-xexpr</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr~3f%29%29" class="RktValLink" data-pltdoc="x">xexpr?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-in</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._and%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._file-exists%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">file-exists?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">reads the standard input device (until closed) or the content of file
<span class="RktVar">f</span> and produces it as an X-expression, including whitespace such as tabs and newlines.</div></p><p>Assumption: the file <span class="RktSym">f</span> or the selected input device contains an
XML element. It assumes the file contains HTML-like text and reads it as XML.</p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-xexpr%29%29" class="RktValLink" data-pltdoc="x">read-xexpr</a></span><span class="hspace"> </span><span class="RktVal">"data.xml"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(pre () "\nhello world\ngood bye\n\ni, for 1, am done\n")</span></p></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">assuming the file named <span class="RktVal">"data.xml"</span> has this shape:
</div><div class="SIntrapara"><blockquote class="SubFlow"><table cellspacing="0" cellpadding="0" class="FileBox"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt"><pre></span></p></td></tr><tr><td><p><span class="stt">hello world</span></p></td></tr><tr><td><p><span class="stt">good bye</span></p></td></tr><tr><td><p><span class="stt"></span><span class="hspace"> </span></p></td></tr><tr><td><p><span class="stt">i, for 1, am done</span></p></td></tr><tr><td><p><span class="stt"></pre></span></p></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Note how the result includes <span class="RktVal">"\\n"</span> for the newlines.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-plain-xexpr))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-plain-xexpr%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-plain-xexpr</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr~3f%29%29" class="RktValLink" data-pltdoc="x">xexpr?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-in</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._and%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._file-exists%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">file-exists?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">reads the standard input device (until closed) or the content of file
<span class="RktVar">f</span> and produces it as an X-expression, without whitespace.</div></p><p>Assumption: the file <span class="RktSym">f</span> or the selected input device contains an
XML element and the content of this element are other XML elements and
whitespace. In particular, the XML element does not contain any strings as
elements other than whitespace.</p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-plain-xexpr%29%29" class="RktValLink" data-pltdoc="x">read-plain-xexpr</a></span><span class="hspace"> </span><span class="RktVal">"data-plain.xml"</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktRes">'(pre</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">()</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(line ((text "hello world")))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(line ((text "good bye")))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(line ())</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(line ((text "i, for 1, am done"))))</span></p></td></tr></table></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">assuming the file named <span class="RktVal">"data-plain.xml"</span> has this shape:
</div><div class="SIntrapara"><blockquote class="SubFlow"><table cellspacing="0" cellpadding="0" class="FileBox"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt"><pre></span></p></td></tr><tr><td><p><span class="stt"><line text="hello world" /></span></p></td></tr><tr><td><p><span class="stt"><line text="good bye" /></span></p></td></tr><tr><td><p><span class="stt"><line /></span></p></td></tr><tr><td><p><span class="stt"><line text="i, for 1, am done" /></span></p></td></tr><tr><td><p><span class="stt"></pre></span></p></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Compare this result with the one for <span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-xexpr%29%29" class="RktValLink" data-pltdoc="x">read-xexpr</a></span>.</div></p></li></ul></div></p><p><div class="SIntrapara">There is only one writer function at the moment:
</div><div class="SIntrapara"><ul><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._write-file))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._write-file%29%29" class="RktValDef RktValLink" data-pltdoc="x">write-file</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span><span class="RktVar">cntnt</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">standard-out</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">stdout</span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">cntnt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">sends <span class="RktVar">cntnt</span> to the standard output device or
turns <span class="RktVar">cntnt</span> into the content of file <span class="RktVar">f</span>, located in the
same folder (directory) as the program. If the write succeeds, the
function produces the name of the file (<span class="RktVar">f</span>); otherwise it signals
an error.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=if.html%23%2528form._%2528%2528quote._%7E23%7E25kernel%2529._if%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">if</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3d%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string=?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._write-file%29%29" class="RktValLink" data-pltdoc="x">write-file</a></span><span class="hspace"> </span><span class="RktVal">"output.txt"</span><span class="hspace"> </span><span class="RktVal">"good bye"</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"output.txt"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._write-file%29%29" class="RktValLink" data-pltdoc="x">write-file</a></span><span class="hspace"> </span><span class="RktVal">"output.txt"</span><span class="hspace"> </span><span class="RktVal">"cruel world"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._write-file%29%29" class="RktValLink" data-pltdoc="x">write-file</a></span><span class="hspace"> </span><span class="RktVal">"output.txt"</span><span class="hspace"> </span><span class="RktVal">"cruel world"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">"output.txt"</span></p></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara">After evaluating this examples, the file named <span class="RktVal">"output.txt"</span>
looks like this:
cruel world
Explain why.</div></p></li></ul></div></p><p><span style="font-weight: bold">Warning</span>: The file IO functions in this teachpack are platform
dependent. That is, as long as your programs and your files live on the
same platform, you should not have any problems reading the files that
programs wrote and vice versa. If, however, one of your programs writes a
file on a Windows operating system and if you then copy this output file
to a Mac, reading the copied text file may produce extraneous “return”
characters. Note that this describes only one example of possible
malfunction; there are other cases when trans-platform actions may cause
this teachpack to fail.</p><h5 x-source-module="(lib "teachpack/teachpack.scrbl")" x-part-tag=""Web_Functions"">2.1.2<tt> </tt><a name="(part._.Web_.Functions)"></a>Web Functions</h5><p>All functions that read a web-based XML consume a URL and possibly
additional arguments. They assume that the computer is connected to
specified part of the web, though they tolerate non-existent web pages
(404 errors)</p><ul><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-xexpr/web))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-xexpr%2Fweb%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-xexpr/web</a></span></span><span class="hspace"> </span><span class="RktVar">u</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr~3f%29%29" class="RktValLink" data-pltdoc="x">xexpr?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">u</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">reads the content of URL <span class="RktVar">u</span> and produces the first XML
element as an <span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr~3f%29%29" class="RktValLink" data-pltdoc="x">xexpr?</a></span> including whitespace such as tabs and newlines. If possible, the function interprets the HTML at
the specified URL as XML. The function returns #<span class="RktSym">f</span> if the web page
does not exist (404)</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._read-plain-xexpr/web))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._read-plain-xexpr%2Fweb%29%29" class="RktValDef RktValLink" data-pltdoc="x">read-plain-xexpr/web</a></span></span><span class="hspace"> </span><span class="RktVar">u</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr~3f%29%29" class="RktValLink" data-pltdoc="x">xexpr?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">u</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">reads the content of URL <span class="RktVar">u</span> and produces the first XML
element as an <span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr~3f%29%29" class="RktValLink" data-pltdoc="x">xexpr?</a></span> without whitespace. If possible, the function interprets the HTML at
the specified URL as XML. The function returns #<span class="RktSym">f</span> if the web page
does not exist (404)</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._url-exists~3f))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._url-exists~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">url-exists?</a></span></span><span class="hspace"> </span><span class="RktVar">u</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">u</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">ensures that the specified URL
<span class="RktVar">u</span> does not produce a 404 error.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._xexpr~3f))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">xexpr?</a></span></span><span class="hspace"> </span><span class="RktVar">u</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">u</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym">any?</span></td></tr></table></blockquote></div><div class="SIntrapara">checks that the given value is an
X-expression in the following sense:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="hspace"> </span><a name="(tech._xexpr)"></a><span style="font-style: italic">Xexpr</span><span class="RktCmt"> is one of:</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="hspace"> </span><span class="RktCmt">–</span><span class="RktCmt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="hspace"> </span><span class="RktCmt">–</span><span class="RktCmt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="hspace"> </span><span class="RktCmt">–</span><span class="RktCmt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._number%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">number?</a></span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="hspace"> </span><span class="RktCmt">–</span><span class="RktCmt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">cons</a></span><span class="stt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">cons</a></span><span class="stt"> </span><span class="RktPn">[</span><span class="RktSym">List-of</span><span class="stt"> </span><a href="#%28tech._attribute%29" class="techoutside" data-pltdoc="x"><span class="techinside">Attribute</span></a><span class="RktPn">]</span><span class="stt"> </span><span class="RktPn">[</span><span class="RktSym">List-of</span><span class="stt"> </span><a href="#%28tech._xexpr%29" class="techoutside" data-pltdoc="x"><span class="techinside">Xexpr</span></a><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="hspace"> </span><span class="RktCmt">–</span><span class="RktCmt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">cons</a></span><span class="stt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span><span class="stt"> </span><span class="RktPn">[</span><span class="RktSym">List-of</span><span class="stt"> </span><a href="#%28tech._xexpr%29" class="techoutside" data-pltdoc="x"><span class="techinside">Xexpr</span></a><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="hspace"> </span><a name="(tech._attribute)"></a><span style="font-style: italic">Attribute</span><span class="RktCmt"> is:</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="stt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span><span class="stt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">a</span><span class="stt"> </span><span class="RktVal">"some text"</span><span class="RktPn">)</span><span class="RktCmt"> is called an a-Attribute</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="hspace"> </span><span class="RktCmt">and "some text" is a</span><span class="RktCmt">'</span><span class="RktCmt">s value.</span></td></tr></table></blockquote></div><div class="SIntrapara">Note that full Racket uses a wider notion of X-expression.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._xexpr-as-string))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr-as-string%29%29" class="RktValDef RktValLink" data-pltdoc="x">xexpr-as-string</a></span></span><span class="hspace"> </span><span class="RktVar">x</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr~3f%29%29" class="RktValLink" data-pltdoc="x">xexpr?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">renders the given
X-expression as a string.</div></p></li><li><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed" style="display: inline-table; vertical-align: text-top;"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._2htdp/batch-io..rkt)._url-html-neighbors))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._url-html-neighbors%29%29" class="RktValDef RktValLink" data-pltdoc="x">url-html-neighbors</a></span></span><span class="hspace"> </span><span class="RktVar">u</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">u</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">retrieves the
content of URL <span class="RktVar">u</span> and produces the list of all URLs that refer to
.html pages via an <span class="stt"><a></span> tag.</div></p></li></ul><h5 x-source-module="(lib "teachpack/teachpack.scrbl")" x-part-tag=""Testing"">2.1.3<tt> </tt><a name="(part._.Testing)"></a>Testing</h5><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._2htdp/batch-io..rkt)._simulate-file))"></a><span title="Provided from: 2htdp/batch-io | Package: htdp-lib"><span class="RktSym"><a href="#%28form._%28%28lib._2htdp%2Fbatch-io..rkt%29._simulate-file%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">simulate-file</a></span></span><span class="hspace"> </span><span class="RktVar">process</span><span class="hspace"> </span><span class="RktVar">str</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">simulates a file system for the function <span class="RktVar">process</span>, which reads a
file and may produce one. Note: this form is under development and will be
documented in a precise manner after it is finalized and useful for a wide
audience.</div></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="2htdp2htdp.html" title="backward to "2 HtDP/2e Teachpacks"" data-pltdoc="x">← prev</a> <a href="2htdp2htdp.html" title="up to "2 HtDP/2e Teachpacks"" data-pltdoc="x">up</a> <a href="2htdpimage-guide.html" title="forward to "2.2 Image Guide"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|