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 OAA03330; Wed, 28 Apr 2004 14:38:18 +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 OAA03329 for ; Wed, 28 Apr 2004 14:38:07 +0200 (MET DST) Received: from postfix3-1.free.fr (postfix3-1.free.fr [213.228.0.44]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3SCc6YM016471 for ; Wed, 28 Apr 2004 14:38:06 +0200 Received: from warp (lns-th2-5f-81-56-197-80.adsl.proxad.net [81.56.197.80]) by postfix3-1.free.fr (Postfix) with SMTP id 25742C53F7; Wed, 28 Apr 2004 14:37:22 +0200 (CEST) Message-ID: <010501c42d1d$86ed32d0$ef01a8c0@warp> From: "Nicolas Cannasse" To: , "Yaron M. Minsky" Cc: "Brian Hurt" , "Martin Berger" , "The Caml Trade" References: <1083140676.9537.831.camel@pelican.wigram> <1083151902.29774.18.camel@localhost.localdomain> <1083154175.9537.944.camel@pelican.wigram> Subject: Re: [Caml-list] [ANN] The Missing Library Date: Wed, 28 Apr 2004 14:36:30 +0200 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.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 iterator:01 iterator:01 abstraction:01 functorial:01 expressive:01 'map':01 polynomial:01 'map':01 extlib:01 enum:01 extlib:01 enums:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > Why can't you do this kind of in ocaml? Returning something like a > > "next" function would seem to give you a very basic (but usable) > > iterator. Which part of the iterator abstraction can't you do? > > I suggest you try it. I don't know how to answer the question. > I think the answer is 'C++ templates provide functorial > polymorphism (polyadicity), Ocaml has no such expressive power.' > > HOF's like 'map' and 'fold' make sense > for polynomial data structures -- lists and trees etc. > But you have to write 'List.map' or 'Array.map'. There > is no single 'map' which works for all data structures > in Ocaml. There is ExtLib Enum.map that's pretty good at doing that. > There is in C++, and its a one line idiom: > > // STL copy > for(; i!=e; ++i) *o++ = *i++; > > Fold is as easy to define (called Accumulate in STL). > > These definitions are polyadic. They work for ALL > data structures -- provided they have iterators > of course :D That's exactly the same as ExtLib enums : define an enumerator for your data structure, and you can apply a full range of algorithms on it. I don't really understand the difference with STL. Regards, 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