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 GAA21760; Sat, 14 Jul 2001 06:41:15 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 GAA21741 for ; Sat, 14 Jul 2001 06:41:14 +0200 (MET DST) Received: from str12.sobor.org (adsl-63-198-183-99.dsl.snfc21.pacbell.net [63.198.183.99]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f6E4fDf09754 for ; Sat, 14 Jul 2001 06:41:13 +0200 (MET DST) Received: from quasar.ipa.nw.ru (anza.sobor.org [192.168.123.51]) by str12.sobor.org (Postfix) with ESMTP id 700C4AC6D2 for ; Fri, 13 Jul 2001 21:28:06 -0700 (PDT) Message-ID: <3B4FCD2B.FC68C181@quasar.ipa.nw.ru> Date: Fri, 13 Jul 2001 21:40:11 -0700 From: "Alexander V. Voinov" Organization: Fear of the Lord is the beginning of wisdom X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: "caml-list@inria.fr" Subject: Re: [Caml-list] Generation of streams is slow References: <3B4F70D7.82E58A91@quasar.ipa.nw.ru> <20010714042701.A24266@verdot.inria.fr> <3B4FB39D.10D1F6D5@quasar.ipa.nw.ru> <20010714060417.A25766@verdot.inria.fr> <3B4FC748.F9E14008@quasar.ipa.nw.ru> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk "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