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 WAA01291; Sun, 26 Sep 2004 22:14:29 +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 WAA01728 for ; Sun, 26 Sep 2004 22:14:28 +0200 (MET DST) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.207]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i8QKER0I028093 for ; Sun, 26 Sep 2004 22:14:28 +0200 Received: by mproxy.gmail.com with SMTP id 77so3564328rnk for ; Sun, 26 Sep 2004 13:14:20 -0700 (PDT) Received: by 10.38.163.10 with SMTP id l10mr39737rne; Sun, 26 Sep 2004 13:14:20 -0700 (PDT) Received: by 10.38.75.19 with HTTP; Sun, 26 Sep 2004 13:14:20 -0700 (PDT) Message-ID: <7f8e92aa04092613141479823e@mail.gmail.com> Date: Sun, 26 Sep 2004 23:14:20 +0300 From: Radu Grigore Reply-To: Radu Grigore To: Jon Harrop Subject: Re: [Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features Cc: caml-list In-Reply-To: <200409261951.52609.jon@jdh30.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable References: <20040925225246.48566.qmail@web53010.mail.yahoo.com> <200409261405.37558.jon@jdh30.plus.com> <1096209379.28613.64.camel@pelican.wigram> <200409261951.52609.jon@jdh30.plus.com> X-Miltered: at nez-perce with ID 41572323.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 val:01 val:01 generic:01 abstraction:01 generic:01 preserving:01 ocaml:01 sep:01 namely:02 float:02 float:02 iterators:02 wrote:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 26 Sep 2004 19:51:52 +0100, Jon Harrop wrote: > > Nope. That only works for a limited class algorithms. > > Try a map function.. woops, you can't type it .. :) > Yes you can: > # let vec_add map2 =3D map2 ( +. );; > val vec_add : ((float -> float -> float) -> 'a) -> 'a =3D >=20 > So you can then do: >=20 > # let list_add =3D vec_add List.map2;; > val list_add : float list -> float list -> float list =3D >=20 > I think you're thinking of a function to convert between 'a and 'b contai= ner > types. I think the idea is that you can't write a _generic_ map. All you did above is a dipatcher that gives the job to a specialized map function: List.map2. The accumulate function in C++ is not a simple dispatcher. It can implement the logic of "fold" because there is an extra level of abstraction: iterators. But what John says is possible in FISh (namely, writing a generic, shape preserving map) sounds quite cool. regards, radu "Get your data structures correct first and the rest of the program will write itself." =E2=80=93 David Jones. http://rgrig.idilis.ro/ ------------------- 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