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 EAA25335; Wed, 7 May 2003 04:06:48 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 EAA25569 for ; Wed, 7 May 2003 04:06:46 +0200 (MET DST) Received: from psyche.kaba.or.jp (psyche.kaba.or.jp [202.249.19.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h4726iT26598 for ; Wed, 7 May 2003 04:06:44 +0200 (MET DST) Received: from mail.kaba.or.jp (cascade.kaba.or.jp [202.249.19.34]) by psyche.kaba.or.jp (Postfix) with ESMTP id B6A9E229F9; Wed, 7 May 2003 11:06:42 +0900 (JST) Received: from WARP (dhcp04.kaba.or.jp [202.249.19.39]) by mail.kaba.or.jp (Postfix) with SMTP id 1C11649A6B; Wed, 7 May 2003 11:06:41 +0900 (JST) Message-ID: <006301c3143d$25b511d0$2713f9ca@WARP> From: "Nicolas Cannasse" To: "Diego Olivier Fernandez Pons" Cc: "Caml List" References: Subject: Re: [Caml-list] Two types of efficiency (Was Efficiency of 'a list) Date: Wed, 7 May 2003 11:05:35 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 extlib:01 enum:01 abstracted:01 ocaml:01 nicolas:01 int:01 uniform:02 functionnal:02 exception:02 purely:02 module:03 differs:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > Few people here are currently running the "ExtLib" - ocaml extended > > library - project, and are trying to answer theses questions. For an > > example of a structure that can be used to convert from and between > > several different data structures, you could have a look at the Enum > > module from the ExtLib CVS here : > > I read the code but I am afraid I didn't catch the point : what is the > difference between the 'enum' data structure and a ('a * int) stream ? I agree that an Enum is near from a Stream, but it differs in several points : - as it is purely functional, you can create quite exotic count and next functions, while Stream.from is only working with indexes, and is having a little cost due to the usage of 'a option instead of an exception. - Enum provide easy support for functional operations such as map, while doing it with stream require a little bit of thinking (and from usage) - with a stream, you have access to a "next" functions : you cannot do something like this with Enum . In most cases, you always want to process all your elements in the same way. Enum does not provide user access to next, you can only do iter. In a short way : Stream is designed more as a "tokenizer" where you're querying items one by one, while Enum is more an uniform collection of items, abstracted in a purely fonctional way. > Why is it more convenient than other data structures as an itermediate > data representation ? It's not a data structure since it does not physically store any elements, it can be seen as a common interface from different data structures wanting to provide support for it. See ExtList.of_enum , ExtList.enum, ExtArray.of_enum and ExtArray.enum , one can do the following : let e = ExtList.enum l in let e' = Enum.map f e in ExtArray.of_enum e' To map-and-convert a list to an array. Quite convenient in fact, but I agree Enum is not the Graal of functionnal programming, just a small convenient interface. Nicolas Cannasse ------------------- 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