man-pages/man3/Stdlib.Stream.3o.html
2021-03-31 01:06:50 +01:00

328 lines
4.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Stdlib.Stream</TITLE>
</HEAD><BODY>
<H1>Stdlib.Stream</H1>
Section: OCaml library (3o)<BR>Updated: 2020-01-30<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
Stdlib.Stream - no description
<A NAME="lbAC">&nbsp;</A>
<H2>Module</H2>
Module Stdlib.Stream
<A NAME="lbAD">&nbsp;</A>
<H2>Documentation</H2>
<P>
Module
<B>Stream</B>
<BR>&nbsp;:&nbsp;
<B>(module Stdlib__stream)</B>
<P>
<P>
<P>
<P>
<P>
<P>
<P>
<I>type </I>
<B>'a</B>
<I>t </I>
<P>
<P>
The type of streams holding values of type
<B>'a</B>
.
<P>
<P>
<P>
<I>exception Failure </I>
<P>
<P>
Raised by parsers when none of the first components of the stream
patterns is accepted.
<P>
<P>
<P>
<I>exception Error </I>
<B>of </B>
<B>string</B>
<P>
<P>
Raised by parsers when the first component of a stream pattern is
accepted, but one of the following components is rejected.
<P>
<P>
<P>
<P>
<A NAME="lbAE">&nbsp;</A>
<H3>Stream builders</H3>
<P>
<P>
<P>
<I>val from </I>
:
<B>(int -&gt; 'a option) -&gt; 'a t</B>
<P>
<P>
<B>Stream.from f</B>
returns a stream built from the function
<B>f</B>
.
To create a new stream element, the function
<B>f</B>
is called with
the current stream count. The user function
<B>f</B>
must return either
<B>Some &lt;value&gt;</B>
for a value or
<B>None</B>
to specify the end of the
stream.
<P>
Do note that the indices passed to
<B>f</B>
may not start at
<B>0</B>
in the
general case. For example,
<B>[&lt; '0; '1; Stream.from f &gt;]</B>
would call
<B>f</B>
the first time with count
<B>2</B>
.
<P>
<P>
<P>
<I>val of_list </I>
:
<B>'a list -&gt; 'a t</B>
<P>
Return the stream holding the elements of the list in the same
order.
<P>
<P>
<P>
<I>val of_string </I>
:
<B>string -&gt; char t</B>
<P>
Return the stream of the characters of the string parameter.
<P>
<P>
<P>
<I>val of_bytes </I>
:
<B>bytes -&gt; char t</B>
<P>
Return the stream of the characters of the bytes parameter.
<P>
<P>
<B>Since</B>
4.02.0
<P>
<P>
<P>
<I>val of_channel </I>
:
<B>in_channel -&gt; char t</B>
<P>
Return the stream of the characters read from the input channel.
<P>
<P>
<P>
<P>
<A NAME="lbAF">&nbsp;</A>
<H3>Stream iterator</H3>
<P>
<P>
<P>
<I>val iter </I>
:
<B>('a -&gt; unit) -&gt; 'a t -&gt; unit</B>
<P>
<P>
<B>Stream.iter f s</B>
scans the whole stream s, applying function
<B>f</B>
in turn to each stream element encountered.
<P>
<P>
<P>
<P>
<A NAME="lbAG">&nbsp;</A>
<H3>Predefined parsers</H3>
<P>
<P>
<P>
<I>val next </I>
:
<B>'a t -&gt; 'a</B>
<P>
Return the first element of the stream and remove it from the
stream. Raise
<B>Stream.Failure</B>
if the stream is empty.
<P>
<P>
<P>
<I>val empty </I>
:
<B>'a t -&gt; unit</B>
<P>
Return
<B>()</B>
if the stream is empty, else raise
<B>Stream.Failure</B>
.
<P>
<P>
<P>
<P>
<A NAME="lbAH">&nbsp;</A>
<H3>Useful functions</H3>
<P>
<P>
<P>
<I>val peek </I>
:
<B>'a t -&gt; 'a option</B>
<P>
Return
<B>Some</B>
of &quot;the first element&quot; of the stream, or
<B>None</B>
if
the stream is empty.
<P>
<P>
<P>
<I>val junk </I>
:
<B>'a t -&gt; unit</B>
<P>
Remove the first element of the stream, possibly unfreezing
it before.
<P>
<P>
<P>
<I>val count </I>
:
<B>'a t -&gt; int</B>
<P>
Return the current count of the stream elements, i.e. the number
of the stream elements discarded.
<P>
<P>
<P>
<I>val npeek </I>
:
<B>int -&gt; 'a t -&gt; 'a list</B>
<P>
<P>
<B>npeek n</B>
returns the list of the
<B>n</B>
first elements of
the stream, or all its remaining elements if less than
<B>n</B>
elements are available.
<P>
<P>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">Module</A><DD>
<DT id="3"><A HREF="#lbAD">Documentation</A><DD>
<DL>
<DT id="4"><A HREF="#lbAE">Stream builders</A><DD>
<DT id="5"><A HREF="#lbAF">Stream iterator</A><DD>
<DT id="6"><A HREF="#lbAG">Predefined parsers</A><DD>
<DT id="7"><A HREF="#lbAH">Useful functions</A><DD>
</DL>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:57 GMT, March 31, 2021
</BODY>
</HTML>