From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A9031BB9C for ; Thu, 1 Dec 2005 01:55:41 +0100 (CET) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.207]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jB10teLF016779 for ; Thu, 1 Dec 2005 01:55:41 +0100 Received: by zproxy.gmail.com with SMTP id 8so136669nzo for ; Wed, 30 Nov 2005 16:55:40 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=eOAyklop8LxFKhgEFd6sxQBvNHL029XAJpVGEdHMuwi6qIcB+G26VoCZ9vjx1eWAzTpwviGZbYxRJfTOwq1Yw4yRoPGuF6Zo3dD3fnV2qFAH1nzGRNipoRgOVeMyIvMrKGsgg7Kfodct0ToeT+Uc2eo4YZAbzekvA79DI06C0+o= Received: by 10.64.196.9 with SMTP id t9mr554346qbf; Wed, 30 Nov 2005 16:55:38 -0800 (PST) Received: by 10.65.35.10 with HTTP; Wed, 30 Nov 2005 16:55:38 -0800 (PST) Message-ID: Date: Thu, 1 Dec 2005 13:55:38 +1300 From: Jonathan Roewen To: caml-list@yquem.inria.fr Subject: [Caml-list] composing functions... MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Miltered: at concorde with ID 438E4A0C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 char:01 inherit:01 inherit:01 functions:01 functions:01 tuples:01 int:01 int:01 instances:02 objects:02 let:03 let:03 anyway:05 classes:06 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 Hi, I'm getting a bit stuck, and am wondering if there's anyway to compose a bunch of functions together easily without having to pre-maturely apply any of them. My current idea is trying to use objects, like: class virtual ['a] composable =3D object (self) method compose a b =3D self#apply a @ b method virtual apply : 'a -> int list end;; class c1 =3D object inherit ['a] composable method apply (a,b,c) -> [a;b;int_of_char c] end;; class c2 =3D object inherit ['a] composable method apply a -> [a] end;; let o1 =3D new c1 and o2 =3D new c2;; I can do something like let f a1 a2 =3D o1#compose a1 (o2#compose a2 []);; and get a list back... But what I'm wondering is if it's possible to make a generic compose function that takes say a list of either classes or object instances, and return a new function that I can apply the bunch of tuples to. Theory: let f =3D compose [o1;o2];; f a1 a2;; maybe it's not worth the hassle (if it's even possible). Jonathan