/usr/share/doc/racket/reference/streams.html is in racket-doc 6.7-3.
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 | <!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>4.14.2 Streams</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="extras.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.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="../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="../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-weight: bold">The Racket Reference</span></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="model.html" class="tocviewlink" data-pltdoc="x">Language Model</a></td></tr><tr><td align="right">2 </td><td><a href="notation.html" class="tocviewlink" data-pltdoc="x">Notation for Documentation</a></td></tr><tr><td align="right">3 </td><td><a href="syntax.html" class="tocviewlink" data-pltdoc="x">Syntactic Forms</a></td></tr><tr><td align="right">4 </td><td><a href="data.html" class="tocviewselflink" data-pltdoc="x">Datatypes</a></td></tr><tr><td align="right">5 </td><td><a href="structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">6 </td><td><a href="mzlib_class.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">7 </td><td><a href="mzlib_unit.html" class="tocviewlink" data-pltdoc="x">Units</a></td></tr><tr><td align="right">8 </td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">9 </td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">10 </td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Control Flow</a></td></tr><tr><td align="right">11 </td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Parallelism</a></td></tr><tr><td align="right">12 </td><td><a href="Macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">13 </td><td><a href="input-and-output.html" class="tocviewlink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">14 </td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Reflection and Security</a></td></tr><tr><td align="right">15 </td><td><a href="os.html" class="tocviewlink" data-pltdoc="x">Operating System</a></td></tr><tr><td align="right">16 </td><td><a href="memory.html" class="tocviewlink" data-pltdoc="x">Memory Management</a></td></tr><tr><td align="right">17 </td><td><a href="unsafe.html" class="tocviewlink" data-pltdoc="x">Unsafe Operations</a></td></tr><tr><td align="right">18 </td><td><a href="running.html" class="tocviewlink" data-pltdoc="x">Running Racket</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</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>4 </td><td><a href="data.html" class="tocviewlink" data-pltdoc="x">Datatypes</a></td></tr></table><div class="tocviewsublist" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">4.1 </td><td><a href="booleans.html" class="tocviewlink" data-pltdoc="x">Booleans and Equality</a></td></tr><tr><td align="right">4.2 </td><td><a href="numbers.html" class="tocviewlink" data-pltdoc="x">Numbers</a></td></tr><tr><td align="right">4.3 </td><td><a href="strings.html" class="tocviewlink" data-pltdoc="x">Strings</a></td></tr><tr><td align="right">4.4 </td><td><a href="bytestrings.html" class="tocviewlink" data-pltdoc="x">Byte Strings</a></td></tr><tr><td align="right">4.5 </td><td><a href="characters.html" class="tocviewlink" data-pltdoc="x">Characters</a></td></tr><tr><td align="right">4.6 </td><td><a href="symbols.html" class="tocviewlink" data-pltdoc="x">Symbols</a></td></tr><tr><td align="right">4.7 </td><td><a href="regexp.html" class="tocviewlink" data-pltdoc="x">Regular Expressions</a></td></tr><tr><td align="right">4.8 </td><td><a href="keywords.html" class="tocviewlink" data-pltdoc="x">Keywords</a></td></tr><tr><td align="right">4.9 </td><td><a href="pairs.html" class="tocviewlink" data-pltdoc="x">Pairs and Lists</a></td></tr><tr><td align="right">4.10 </td><td><a href="mpairs.html" class="tocviewlink" data-pltdoc="x">Mutable Pairs and Lists</a></td></tr><tr><td align="right">4.11 </td><td><a href="vectors.html" class="tocviewlink" data-pltdoc="x">Vectors</a></td></tr><tr><td align="right">4.12 </td><td><a href="boxes.html" class="tocviewlink" data-pltdoc="x">Boxes</a></td></tr><tr><td align="right">4.13 </td><td><a href="hashtables.html" class="tocviewlink" data-pltdoc="x">Hash Tables</a></td></tr><tr><td align="right">4.14 </td><td><a href="sequences_streams.html" class="tocviewselflink" data-pltdoc="x">Sequences and Streams</a></td></tr><tr><td align="right">4.15 </td><td><a href="dicts.html" class="tocviewlink" data-pltdoc="x">Dictionaries</a></td></tr><tr><td align="right">4.16 </td><td><a href="sets.html" class="tocviewlink" data-pltdoc="x">Sets</a></td></tr><tr><td align="right">4.17 </td><td><a href="procedures.html" class="tocviewlink" data-pltdoc="x">Procedures</a></td></tr><tr><td align="right">4.18 </td><td><a href="void.html" class="tocviewlink" data-pltdoc="x">Void</a></td></tr><tr><td align="right">4.19 </td><td><a href="undefined.html" class="tocviewlink" data-pltdoc="x">Undefined</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>4.14 </td><td><a href="sequences_streams.html" class="tocviewlink" data-pltdoc="x">Sequences and Streams</a></td></tr></table><div class="tocviewsublistbottom" style="display: block;" id="tocview_2"><table cellspacing="0" cellpadding="0"><tr><td align="right">4.14.1 </td><td><a href="sequences.html" class="tocviewlink" data-pltdoc="x">Sequences</a></td></tr><tr><td align="right">4.14.2 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Streams</a></td></tr><tr><td align="right">4.14.3 </td><td><a href="Generators.html" class="tocviewlink" data-pltdoc="x">Generators</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-empty~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>empty?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-first%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>first</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-rest%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>rest</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream-cons%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">stream-<wbr></wbr>cons</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">stream</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%2A%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">stream*</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._in-stream%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">in-<wbr></wbr>stream</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._empty-stream%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">empty-<wbr></wbr>stream</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-~3elist%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>>list</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-length%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>length</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-ref%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>ref</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-tail%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>tail</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-append%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>append</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-map%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>map</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-andmap%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>andmap</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-ormap%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>ormap</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-for-each%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>for-<wbr></wbr>each</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-fold%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>fold</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-count%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>count</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-filter%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>filter</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-add-between%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream-<wbr></wbr>add-<wbr></wbr>between</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._for%2Fstream%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for/<span class="mywbr"> </span>stream</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._for%2A%2Fstream%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">for*/<span class="mywbr"> </span>stream</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._gen~3astream%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">gen:<span class="mywbr"> </span>stream</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._prop~3astream%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">prop:<span class="mywbr"> </span>stream</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream%2Fc%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stream/<span class="mywbr"> </span>c</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.7", "../");" 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.7");">top</a></span><span class="navright"> <a href="sequences.html" title="backward to "4.14.1 Sequences"" data-pltdoc="x">← prev</a> <a href="sequences_streams.html" title="up to "4.14 Sequences and Streams"" data-pltdoc="x">up</a> <a href="Generators.html" title="forward to "4.14.3 Generators"" data-pltdoc="x">next →</a></span> </div><h5 x-source-module="(lib "scribblings/reference/reference.scrbl")" x-source-pkg="racket-doc" x-part-tag=""streams"">4.14.2<tt> </tt><a name="(part._streams)"></a><a name="(mod-path._racket/stream)"></a>Streams</h5><p>A <a name="(tech._stream)"></a><span style="font-style: italic">stream</span> is a kind of <a href="sequences.html#%28tech._sequence%29" class="techoutside" data-pltdoc="x"><span class="techinside">sequence</span></a> that supports
functional iteration via <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-first%29%29" class="RktValLink" data-pltdoc="x">stream-first</a></span> and
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-rest%29%29" class="RktValLink" data-pltdoc="x">stream-rest</a></span>. The <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream-cons%29%29" class="RktStxLink" data-pltdoc="x">stream-cons</a></span> form constructs a lazy
stream, but plain lists can be used as streams, and functions such as
<span class="RktSym"><a href="sequences.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._in-range%29%29" class="RktValLink" data-pltdoc="x">in-range</a></span> and <span class="RktSym"><a href="sequences.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._in-naturals%29%29" class="RktValLink" data-pltdoc="x">in-naturals</a></span> also create streams.</p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/stream</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">base</span></span></td></tr></table></div><div class="SIntrapara">The bindings documented in this section are provided by the <a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/stream</span></a> and <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket</span></a> libraries, but not <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/base</span></a>.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream~3f))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">v</span> can be used as a <a href="#%28tech._stream%29" class="techoutside" data-pltdoc="x"><span class="techinside">stream</span></a>,
<span class="RktVal">#f</span> otherwise.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-empty~3f))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-empty~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-empty?</a></span></span><span class="hspace"> </span><span class="RktVar">s</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">s</span> has no elements, <span class="RktVal">#f</span>
otherwise.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-first))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-first%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-first</a></span></span><span class="hspace"> </span><span class="RktVar">s</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span></p></blockquote></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="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29" class="RktValLink" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._not%2Fc%29%29" class="RktValLink" data-pltdoc="x">not/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-empty~3f%29%29" class="RktValLink" data-pltdoc="x">stream-empty?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Returns the value(s) of the first element in <span class="RktVar">s</span>.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-rest))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-rest%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-rest</a></span></span><span class="hspace"> </span><span class="RktVar">s</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></p></blockquote></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="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29" class="RktValLink" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._not%2Fc%29%29" class="RktValLink" data-pltdoc="x">not/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-empty~3f%29%29" class="RktValLink" data-pltdoc="x">stream-empty?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a stream that is equivalent to <span class="RktVar">s</span> without its first
element.</div></p><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._racket/stream..rkt)._stream-cons))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream-cons%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">stream-cons</a></span></span><span class="hspace"> </span><span class="RktVar">first-expr</span><span class="hspace"> </span><span class="RktVar">rest-expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Produces a lazy stream for which <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-first%29%29" class="RktValLink" data-pltdoc="x">stream-first</a></span> forces the
evaluation of <span class="RktVar">first-expr</span> to produce the first element of
the stream, and <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-rest%29%29" class="RktValLink" data-pltdoc="x">stream-rest</a></span> forces the evaluation of
<span class="RktVar">rest-expr</span> to produce a stream for the rest of the returned
stream.</div></p><p>The first element of the stream as produced by <span class="RktVar">first-expr</span>
must be a single value. The <span class="RktVar">rest-expr</span> must produce a stream
when it is evaluated, otherwise the <span class="RktSym"><a href="exns.html#%28def._%28%28quote._~23~25kernel%29._exn~3afail~3acontract~3f%29%29" class="RktValLink" data-pltdoc="x">exn:fail:contract?</a></span> exception is raised.</p><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._racket/stream..rkt)._stream))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">stream</a></span></span><span class="hspace"> </span><span class="RktVar">expr</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">A shorthand for nested <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream-cons%29%29" class="RktStxLink" data-pltdoc="x">stream-cons</a></span>es ending with
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._empty-stream%29%29" class="RktValLink" data-pltdoc="x">empty-stream</a></span>.</div></p><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._racket/stream..rkt)._stream*))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%2A%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">stream*</a></span></span><span class="hspace"> </span><span class="RktVar">expr</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">A shorthand for nested <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream-cons%29%29" class="RktStxLink" data-pltdoc="x">stream-cons</a></span>es, but the final <span class="RktVar">expr</span>
must be a stream, and it is used as the rest of the stream instead of
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._empty-stream%29%29" class="RktValLink" data-pltdoc="x">empty-stream</a></span>. Similar to <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%2A%29%29" class="RktValLink" data-pltdoc="x">list*</a></span> but for streams.</div></p><p class="SHistory">Added in version 6.3 of package <span class="stt">base</span>.</p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._in-stream))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._in-stream%29%29" class="RktValDef RktValLink" data-pltdoc="x">in-stream</a></span></span><span class="hspace"> </span><span class="RktVar">s</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="sequences.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._sequence~3f%29%29" class="RktValLink" data-pltdoc="x">sequence?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a sequence that is equivalent to <span class="RktVar">s</span>.
</div><div class="SIntrapara">An <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._in-stream%29%29" class="RktValLink" data-pltdoc="x">in-stream</a></span> application can provide better performance for streams iteration when it appears directly in a <span class="RktSym"><a href="for.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for%29%29" class="RktStxLink" data-pltdoc="x">for</a></span> clause.</div></p><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>value</p></div></div><p class="RForeground"><a name="(def._((lib._racket/stream..rkt)._empty-stream))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._empty-stream%29%29" class="RktValDef RktValLink" data-pltdoc="x">empty-stream</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">A stream with no elements.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-~3elist))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-~3elist%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream->list</a></span></span><span class="hspace"> </span><span class="RktVar">s</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a list whose elements are the elements of <span class="RktVar">s</span>, each
of which must be a single value. If <span class="RktVar">s</span> is infinite, this
function does not terminate.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-length))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-length%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-length</a></span></span><span class="hspace"> </span><span class="RktVar">s</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._exact-nonnegative-integer~3f%29%29" class="RktValLink" data-pltdoc="x">exact-nonnegative-integer?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns the number of elements of <span class="RktVar">s</span>. If <span class="RktVar">s</span> is
infinite, this function does not terminate.</div></p><p>In the case of lazy streams, this function forces evaluation only of
the sub-streams, and not the stream’s elements.</p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-ref))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-ref%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-ref</a></span></span><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span><span class="RktVar">i</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">i</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._exact-nonnegative-integer~3f%29%29" class="RktValLink" data-pltdoc="x">exact-nonnegative-integer?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns the <span class="RktVar">i</span>th element of <span class="RktVar">s</span> (which may be
multiple values).</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-tail))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-tail%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-tail</a></span></span><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span><span class="RktVar">i</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">i</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._exact-nonnegative-integer~3f%29%29" class="RktValLink" data-pltdoc="x">exact-nonnegative-integer?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a stream equivalent to <span class="RktVar">s</span>, except that the first
<span class="RktVar">i</span> elements are omitted.</div></p><p>In case extracting elements from <span class="RktVar">s</span> involves a side effect,
they will not be extracted until the first element is extracted from
the resulting stream.</p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-append))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-append%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-append</a></span></span><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a stream that contains all elements of each stream in the
order they appear in the original streams. The new stream is
constructed lazily, while the last given stream is used in the tail
of the result.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-map))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-map%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-map</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="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</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="RktSym"><a href="procedures.html#%28def._%28%28quote._~23~25kernel%29._procedure~3f%29%29" class="RktValLink" data-pltdoc="x">procedure?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a stream that contains <span class="RktVar">f</span> applied to each element of
<span class="RktVar">s</span>. The new stream is constructed lazily.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-andmap))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-andmap%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-andmap</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="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</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="function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></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="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">f</span> returns a true result on every
element of <span class="RktVar">s</span>. If <span class="RktVar">s</span> is infinite and <span class="RktVar">f</span>
never returns a false result, this function does not terminate.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-ormap))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-ormap%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-ormap</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="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</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="function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></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="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">f</span> returns a true result on some
element of <span class="RktVar">s</span>. If <span class="RktVar">s</span> is infinite and <span class="RktVar">f</span>
never returns a true result, this function does not terminate.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-for-each))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-for-each%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-for-each</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="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</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="function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></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="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Applies <span class="RktVar">f</span> to each element of <span class="RktVar">s</span>. If <span class="RktVar">s</span> is
infinite, this function does not terminate.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-fold))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-fold%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-fold</a></span></span><span class="hspace"> </span><span class="RktVar">f</span><span class="hspace"> </span><span class="RktVar">i</span><span class="hspace"> </span><span class="RktVar">s</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</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="function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">i</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Folds <span class="RktVar">f</span> over each element of <span class="RktVar">s</span> with <span class="RktVar">i</span> as
the initial accumulator. If <span class="RktVar">s</span> is infinite, this function
does not terminate.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-count))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-count%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-count</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="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._exact-nonnegative-integer~3f%29%29" class="RktValLink" data-pltdoc="x">exact-nonnegative-integer?</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="RktSym"><a href="procedures.html#%28def._%28%28quote._~23~25kernel%29._procedure~3f%29%29" class="RktValLink" data-pltdoc="x">procedure?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns the number of elements in <span class="RktVar">s</span> for which <span class="RktVar">f</span>
returns a true result. If <span class="RktVar">s</span> is infinite, this function
does not terminate.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-filter))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-filter%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-filter</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="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</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="function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></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="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a stream whose elements are the elements of <span class="RktVar">s</span> for
which <span class="RktVar">f</span> returns a true result. Although the new stream is
constructed lazily, if <span class="RktVar">s</span> has an infinite number of elements
where <span class="RktVar">f</span> returns a false result in between two elements
where <span class="RktVar">f</span> returns a true result, then operations on this
stream will not terminate during the infinite sub-stream.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream-add-between))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-add-between%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream-add-between</a></span></span><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span><span class="RktVar">e</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">s</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">e</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a stream whose elements are the elements of <span class="RktVar">s</span>, but
with <span class="RktVar">e</span> between each pair of elements in <span class="RktVar">s</span>. The
new stream is constructed lazily.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><table cellspacing="0" cellpadding="0" class="together"><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._racket/stream..rkt)._for/stream))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._for%2Fstream%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for/stream</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">for-clause</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body-or-break</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="hspace"> </span><span class="RktVar">body</span><span class="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><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._racket/stream..rkt)._for*/stream))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._for%2A%2Fstream%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">for*/stream</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">for-clause</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body-or-break</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="hspace"> </span><span class="RktVar">body</span><span class="RktPn">)</span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Iterates like <span class="RktSym"><a href="for.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for/list</a></span> and <span class="RktSym"><a href="for.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for%2A%2Flist%29%29" class="RktStxLink" data-pltdoc="x">for*/list</a></span>, respectively, but the
results are lazily collected into a <a href="#%28tech._stream%29" class="techoutside" data-pltdoc="x"><span class="techinside">stream</span></a> instead of a list.</div></p><p>Unlike most <span class="RktSym"><a href="for.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for%29%29" class="RktStxLink" data-pltdoc="x">for</a></span> forms, these forms are evaluated lazily, so each
<span class="RktVar">body</span> will not be evaluated until the resulting stream is forced. This
allows <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._for%2Fstream%29%29" class="RktStxLink" data-pltdoc="x">for/stream</a></span> and <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._for%2A%2Fstream%29%29" class="RktStxLink" data-pltdoc="x">for*/stream</a></span> to iterate over infinite
sequences, unlike their finite counterparts.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fstream..rkt%29._for%2Fstream%29%29" class="RktStxLink" data-pltdoc="x">for/stream</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace"> </span><span class="RktSym">i</span><span class="hspace"> </span><span class="RktSym">i</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<stream></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-~3elist%29%29" class="RktValLink" data-pltdoc="x">stream->list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._for%2Fstream%29%29" class="RktStxLink" data-pltdoc="x">for/stream</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace"> </span><span class="RktSym">i</span><span class="hspace"> </span><span class="RktSym">i</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(1 4 9)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-ref%29%29" class="RktValLink" data-pltdoc="x">stream-ref</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._for%2Fstream%29%29" class="RktStxLink" data-pltdoc="x">for/stream</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Writing.html#%28def._%28%28lib._racket%2Fprivate%2Fmisc..rkt%29._displayln%29%29" class="RktValLink" data-pltdoc="x">displayln</a></span><span class="hspace"> </span><span class="RktSym">i</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace"> </span><span class="RktSym">i</span><span class="hspace"> </span><span class="RktSym">i</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">1</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktOut">1</span></p></td></tr><tr><td><p><span class="RktOut">2</span></p></td></tr></table></td></tr><tr><td><p><span class="RktRes">4</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-ref%29%29" class="RktValLink" data-pltdoc="x">stream-ref</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._for%2Fstream%29%29" class="RktStxLink" data-pltdoc="x">for/stream</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="sequences.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._in-naturals%29%29" class="RktValLink" data-pltdoc="x">in-naturals</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="hspace"> </span><span class="RktSym">i</span><span class="hspace"> </span><span class="RktSym">i</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">25</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">625</span></p></td></tr></table></blockquote></div></p><p class="SHistory">Added in version 6.3.0.9 of package <span class="stt">base</span>.</p><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>value</p></div></div><p class="RForeground"><a name="(def._((lib._racket/stream..rkt)._gen~3astream))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._gen~3astream%29%29" class="RktValDef RktValLink" data-pltdoc="x">gen:stream</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Associates three methods to a structure type to implement the
<a href="struct-generics.html#%28tech._generic._interface%29" class="techoutside" data-pltdoc="x"><span class="techinside">generic interface</span></a> (see <a href="struct-generics.html" data-pltdoc="x">Generic Interfaces</a>) for
streams.</div></p><p>To supply method implementations, the <span class="RktPn">#:methods</span> keyword
should be used in a structure type definition. The following three
methods should be implemented:</p><ul><li><p><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-empty~3f%29%29" class="RktValLink" data-pltdoc="x">stream-empty?</a></span> : accepts one argument</p></li><li><p><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-first%29%29" class="RktValLink" data-pltdoc="x">stream-first</a></span> : accepts one argument</p></li><li><p><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-rest%29%29" class="RktValLink" data-pltdoc="x">stream-rest</a></span> : accepts one argument</p></li></ul><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="RktStxLink" data-pltdoc="x">define-struct</a></span><span class="hspace"> </span><span class="RktSym">list-stream</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">v</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:methods</span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._gen~3astream%29%29" class="RktValLink" data-pltdoc="x">gen:stream</a></span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-empty~3f%29%29" class="RktValLink" data-pltdoc="x">stream-empty?</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></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="pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._empty~3f%29%29" class="RktValLink" data-pltdoc="x">empty?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">list-stream-v</span><span class="hspace"> </span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></span><span class="RktPn">)</span><span class="RktPn">)</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="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-first%29%29" class="RktValLink" data-pltdoc="x">stream-first</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></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="pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._first%29%29" class="RktValLink" data-pltdoc="x">first</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">list-stream-v</span><span class="hspace"> </span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></span><span class="RktPn">)</span><span class="RktPn">)</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="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-rest%29%29" class="RktValLink" data-pltdoc="x">stream-rest</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></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="pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._rest%29%29" class="RktValLink" data-pltdoc="x">rest</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">list-stream-v</span><span class="hspace"> </span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">l1</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">list-stream</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream~3f%29%29" class="RktValLink" data-pltdoc="x">stream?</a></span><span class="hspace"> </span><span class="RktSym">l1</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-first%29%29" class="RktValLink" data-pltdoc="x">stream-first</a></span><span class="hspace"> </span><span class="RktSym">l1</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">1</span></p></td></tr></table></blockquote></div></p><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>value</p></div></div><p class="RForeground"><a name="(def._((lib._racket/stream..rkt)._prop~3astream))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._prop~3astream%29%29" class="RktValDef RktValLink" data-pltdoc="x">prop:stream</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="structprops.html#%28def._%28%28quote._~23~25kernel%29._struct-type-property~3f%29%29" class="RktValLink" data-pltdoc="x">struct-type-property?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">A deprecated structure type property used to define custom
extensions to the stream API. Use <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._gen~3astream%29%29" class="RktValLink" data-pltdoc="x">gen:stream</a></span> instead.
Accepts a vector of three procedures taking the same arguments as
the methods in <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._gen~3astream%29%29" class="RktValLink" data-pltdoc="x">gen:stream</a></span>.</div></p><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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/stream..rkt)._stream/c))"></a><span title="Provided from: racket/stream, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream%2Fc%29%29" class="RktValDef RktValLink" data-pltdoc="x">stream/c</a></span></span><span class="hspace"> </span><span class="RktVar">c</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="contract-utilities.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fguts..rkt%29._contract~3f%29%29" class="RktValLink" data-pltdoc="x">contract?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">c</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="contract-utilities.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fguts..rkt%29._contract~3f%29%29" class="RktValLink" data-pltdoc="x">contract?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a contract that recognizes streams. All elements of the stream must match
<span class="RktVar">c</span>.</div></p><p>If the <span class="RktVar">c</span> argument is a flat contract or a chaperone contract, then the
result will be a chaperone contract. Otherwise, the result will be an
impersonator contract.</p><p>When an <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fstream..rkt%29._stream%2Fc%29%29" class="RktValLink" data-pltdoc="x">stream/c</a></span> contract is applied to an asynchronous channel,
the result is not <span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._eq~3f%29%29" class="RktValLink" data-pltdoc="x">eq?</a></span> to the input. The result will be either a
<a href="chaperones.html#%28tech._chaperone%29" class="techoutside" data-pltdoc="x"><span class="techinside">chaperone</span></a> or <a href="chaperones.html#%28tech._impersonator%29" class="techoutside" data-pltdoc="x"><span class="techinside">impersonator</span></a> of the input depending on the type of
contract.</p><p>Contracts on streams are evaluated lazily by necessity (since streams may be
infinite). Contract violations will not be raised until the value in violation
is retrieved from the stream. As an exception to this rule, streams that are
lists are checked immediately, as if <span class="RktVar">c</span> had been used with
<span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._listof%29%29" class="RktValLink" data-pltdoc="x">listof</a></span>.</p><p>If a contract is applied to a stream, and that stream is subsequently used as
the tail of another stream (as the second parameter to <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fstream..rkt%29._stream-cons%29%29" class="RktStxLink" data-pltdoc="x">stream-cons</a></span>),
the new elements will not be checked with the contract, but the tail’s elements
will still be enforced.</p><p class="SHistory">Added in version 6.1.1.8 of package <span class="stt">base</span>.</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.7", "../");" 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.7");">top</a></span><span class="navright"> <a href="sequences.html" title="backward to "4.14.1 Sequences"" data-pltdoc="x">← prev</a> <a href="sequences_streams.html" title="up to "4.14 Sequences and Streams"" data-pltdoc="x">up</a> <a href="Generators.html" title="forward to "4.14.3 Generators"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|