caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jonathan Roewen" <jonathan.roewen@gmail.com>
To: Error404 <error92@tlen.pl>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Streams
Date: Thu, 10 Aug 2006 23:40:34 +1200	[thread overview]
Message-ID: <ad8cfe7e0608100440oe075d50y60b2892a48bbb9d2@mail.gmail.com> (raw)
In-Reply-To: <5ebb1214.308e7ea.44db0fae.68763@o2.pl>

The Stream module provides exactly this functionality.

With camlp4o, you can use the old parser syntax too.

#load "camlp4o.cma";

let rec enum_from n = [< 'n; enum_from (n + 1) >];;

let first_10 = Stream.npeek 10 (enum_from 1);;

Streams are also lazily evaluated. More complex examples can be had
too, and there is the parser keyword to deconstruct streams as well.
You should be able to find more info in the camlp4 manual at the caml
site.

Jonathan

On 8/10/06, Error404 <error92@tlen.pl> wrote:
> Hi,
>
> I'm looking for some streams related tutorial or any other info.
> By stream i mean something like this (I don't know exact definition):
>
> open Lazy;;
> type 'a stream = Nil | Cons of 'a Lazy.t * 'a stream Lazy.t;;
>
> (* For example stream of 'integers from x' would look like this: *)
>
> let rec intsfrom x =
>  Cons(lazy x,lazy (intsfrom (x+1)));;
>
> If you know any www/book or anything on this kind of streams please mail me (error92@tlen.pl).
> Many thanks.
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


  reply	other threads:[~2006-08-10 11:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-10 10:51 Streams Error404
2006-08-10 11:40 ` Jonathan Roewen [this message]
2006-08-10 19:02   ` [Caml-list] Streams Chris King
2006-08-10 18:32 ` Martin Jambon
2006-08-11  0:00 ` Jon Harrop
  -- strict thread matches above, loose matches on Subject: below --
2002-07-05 23:05 [Caml-list] Re: generic programming Dave Berry
2002-08-02 14:49 ` [Caml-list] Streams Diego Olivier Fernandez Pons
2002-08-02 15:29   ` Alain Frisch
2002-08-03 14:19     ` Diego Olivier Fernandez Pons
     [not found] <F241eHu7RVLCMUWktUq0000fbc1@hotmail.com>
2002-04-09 18:09 ` [Caml-list] Cannot find Stream Parser Documentation Wolfram Kahl
2002-04-10 11:03   ` [Caml-list] Streams Daniel de Rauglaudre
2002-04-11 14:35     ` Wolfram Kahl
2001-03-27  2:12 [Caml-list] Caml Development Kit Patrick M Doane
2001-03-27  3:15 ` Brian Rogoff
2001-03-27  6:48   ` [Caml-list] Streams Daniel de Rauglaudre
     [not found]     ` <3AC04E85.EE51D597@univ-savoie.fr>
2001-03-27  8:37       ` Daniel de Rauglaudre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ad8cfe7e0608100440oe075d50y60b2892a48bbb9d2@mail.gmail.com \
    --to=jonathan.roewen@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=error92@tlen.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).