English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Generation of streams is slow
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-07-14 (04:41)
From: Alexander V. Voinov <avv@q...>
Subject: Re: [Caml-list] Generation of streams is slow
"Alexander V. Voinov" wrote:
> > Perhaps this version would work (not tested):
> >
> >   let rec parse_stream list s =
> >     match s with parser
> >       [< 'i; s' >] -> begin
> >         if i mod 1000 = 0 then begin
> >           printf "picked element %d\n" i;
> >           flush stdout
> >         end;
> >         parse_stream (i :: list) s'
> >       end
> >     | [< >] -> (printf "end\n"; flush stdout; List.rev list)
> 
> I see, Prolog habits are hard to leave. But this solution doesn't look
> as "natural" as mine, and requires additional time to reverse the
> result. I try to acquire hints for the everyday use, of lists and other
> abstract sequences in this case. Not just a particular problem to solve.

And in general, the inability to pass free variables to be bound later
limits the tail recursion optimization. And forces to use iterations
when they exist (as they do in OCaml).

Alexander
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr