From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 2B0ABBC29 for ; Thu, 10 Aug 2006 13:40:37 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k7ABeacn014241 for ; Thu, 10 Aug 2006 13:40:36 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA25537 for ; Thu, 10 Aug 2006 13:40:36 +0200 (MET DST) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.237]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k7ABeZ9k014234 for ; Thu, 10 Aug 2006 13:40:35 +0200 Received: by wx-out-0506.google.com with SMTP id s7so434424wxc for ; Thu, 10 Aug 2006 04:40:35 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=tlkD9RZq/32dWHIqLPiXbO7obk2IMyzPORYbDuaB5IFSaRgyFP+biPL6D/Ne0WehHJW1e3ZSEhLXRAwH+3iCU5xo1B4HCc1QsIBlxqLXQfFouetj/eOVj1mv8eDqC+eMGz+nK5tn9gsObvLYA6KgYgJh+k6cNFwD2SVYoqttg8Q= Received: by 10.78.132.12 with SMTP id f12mr1183241hud; Thu, 10 Aug 2006 04:40:34 -0700 (PDT) Received: by 10.78.194.4 with HTTP; Thu, 10 Aug 2006 04:40:32 -0700 (PDT) Message-ID: Date: Thu, 10 Aug 2006 23:40:34 +1200 From: "Jonathan Roewen" To: Error404 Subject: Re: [Caml-list] Streams Cc: caml-list@inria.fr In-Reply-To: <5ebb1214.308e7ea.44db0fae.68763@o2.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5ebb1214.308e7ea.44db0fae.68763@o2.pl> X-j-chkmail-Score: MSGID : 44DB1B33.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44DB1B34.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44DB1B33.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; camlp:01 parser:01 syntax:01 camlp:01 rec:01 enum:01 enum:01 npeek:01 parser:01 rec:01 beginner's:01 ocaml:01 bug:01 beginners:01 wrote:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 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 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 >