<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/12/13c766eaa064ba0d0d9a119cd8151d2b"
  from="Nick Grey &lt;nickgrey0112@f...&gt;"
  author="Nick Grey"
  date="2002-12-10T07:39:20"
  subject="Re: [Caml-list] Streams.from"
  prev="2002/12/3f6252c496a44de9d62e600f76053aba"
  next="2002/12/d1fe91a7143c27a0eff87d4d142f116e"
  prev-in-thread="2002/12/dccc53828aa05cb7b933659d7f8e9852"
  next-in-thread="2002/12/453315f436ce183655c9744929e58bee"
  prev-thread="2002/12/5f28c0d6c5868bcafd8e8dd4e701f0b3"
  next-thread="2002/12/303524700573103127c46d2209d89f49"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Streams.from">
<msg 
  url="2002/12/4f26c91200b871153ac571f4e71c7d1f"
  from="Nick Grey &lt;nickgrey0112@f...&gt;"
  author="Nick Grey"
  date="2002-12-09T21:22:03"
  subject="[Caml-list] Streams.from">
<msg 
  url="2002/12/6e81d0c7f05a92745a1fd81063bea87b"
  from="Jean-Christophe Filliatre &lt;Jean-Christophe.Filliatre@l...&gt;"
  author="Jean-Christophe Filliatre"
  date="2002-12-09T22:22:27"
  subject="Re: [Caml-list] Streams.from">
<msg 
  url="2002/12/dccc53828aa05cb7b933659d7f8e9852"
  from="Remi VANICAT &lt;vanicat@l...&gt;"
  author="Remi VANICAT"
  date="2002-12-09T23:54:09"
  subject="Re: [Caml-list] Streams.from">
</msg>
<msg 
  url="2002/12/13c766eaa064ba0d0d9a119cd8151d2b"
  from="Nick Grey &lt;nickgrey0112@f...&gt;"
  author="Nick Grey"
  date="2002-12-10T07:39:20"
  subject="Re: [Caml-list] Streams.from">
</msg>
<msg 
  url="2002/12/453315f436ce183655c9744929e58bee"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-12-10T12:29:09"
  subject="Re: [Caml-list] Streams.from">
</msg>
</msg>
</msg>
</thread>

<contents>
On Mon, Dec 09, 2002 at 11:14:57PM +0100, Jean-Christophe Filliatre wrote:

&gt; No. For instance, repeated calls to Stream.peek will clearly call f
&gt; 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 -&gt; int option = &lt;fun&gt;
# 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 = &lt;abstr&gt;
# 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

</contents>

</message>

