From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA24684; Tue, 10 Dec 2002 08:39:20 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA23976 for caml-list@pauillac.inria.fr; Tue, 10 Dec 2002 08:39:19 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA17671 for ; Tue, 10 Dec 2002 01:00:50 +0100 (MET) Received: from draco.dyndns.org (81-86-232-122.dsl.pipex.com [81.86.232.122]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gBA00nX18368 for ; Tue, 10 Dec 2002 01:00:49 +0100 (MET) Received: from jim by draco.dyndns.org with local (Exim 3.36 #1 (Debian)) id 18LXpR-0008KF-00; Tue, 10 Dec 2002 00:00:49 +0000 Date: Tue, 10 Dec 2002 00:00:48 +0000 From: Nick Grey To: caml-list@inria.fr Cc: Jean-Christophe Filliatre Subject: Re: [Caml-list] Streams.from Message-ID: <20021210000048.GA27713@farrand.net> References: <20021209190448.GB24560@farrand.net> <15861.5601.937494.839811@lri.lri.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <15861.5601.937494.839811@lri.lri.fr> User-Agent: Mutt/1.4i X-Uptime: 19:27:40 up 4 days, 1:43, 2 users, load average: 1.08, 1.03, 1.01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, Dec 09, 2002 at 11:14:57PM +0100, Jean-Christophe Filliatre wrote: > No. For instance, repeated calls to Stream.peek will clearly call f > several times on the same count value (see the code in stdlib/stream.ml) It seems to me that the values are cached, and that repeated calls to peek do not cause f to be called again. Output below demonstrates what I mean. Note that f is called on the first peek but not the second. Similarly with npeek. Also, the parameters to f are 0, 1, 2, 3 ..., with no repeats. Objective Caml version 3.06 # open Stream ;; # let f i = begin print_string "f " ; print_int i ; print_string "\n" ; Some (i*i) end ;; val f : int -> int option = # f 1 ;; f 1 - : int option = Some 1 # f 2 ;; f 2 - : int option = Some 4 # let s = from f ;; val s : int Stream.t = # next s ;; f 0 - : int = 0 # next s ;; f 1 - : int = 1 # peek s ;; f 2 - : int option = Some 4 # peek s ;; - : int option = Some 4 # peek s ;; - : int option = Some 4 # npeek 5 s ;; f 3 f 4 f 5 f 6 - : int list = [4; 9; 16; 25; 36] # npeek 5 s ;; - : int list = [4; 9; 16; 25; 36] ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners