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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 5F215BBBB for ; Thu, 30 Mar 2006 10:38:25 +0200 (CEST) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.199]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k2U8cOv0029446 for ; Thu, 30 Mar 2006 10:38:24 +0200 Received: by zproxy.gmail.com with SMTP id 13so343833nzp for ; Thu, 30 Mar 2006 00:38:24 -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=b9F7VIEN3l1FhWu2WRgQUD/eu5rAlTWksDU9YHW+a6bhakI4MEFEIfLtH7xsD6BdCH+aWsjaydvZ+xzYDU0mODcyfiOcxAusV/+871ZbRTlieDzeShrHr1knMnZ9twVcNwg2XCCb+NiRJIp3mVTFK/8xtDg9bXlpxmbI+8lHSMY= Received: by 10.37.22.37 with SMTP id z37mr2211993nzi; Thu, 30 Mar 2006 00:38:23 -0800 (PST) Received: by 10.36.119.15 with HTTP; Thu, 30 Mar 2006 00:38:23 -0800 (PST) Message-ID: Date: Thu, 30 Mar 2006 20:38:23 +1200 From: "Jonathan Roewen" To: OCaml Subject: [Caml-list] Feature Wish: List comprehensions MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Miltered: at nez-perce with ID 442B9900.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; haskell:01 haskell:01 ocaml:01 caml-list:01 define:01 btw:02 equivalents:02 let:03 let:03 ugly:03 concat:03 complex:04 needing:04 problem:05 suggestions:05 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 having a small problem trying to tidily define an equivalent function to some Haskell code. Haskell: pThen combine p1 p2 toks =3D [ (combine v1 v2, toks2) | (v1,toks1) <- p1 toks, (v2, toks2) <- p2 t= oks1 ] (I'll also be needing to specify equivalents for pThen3 & pThen4). The first isn't too bad... let pThen combine p1 p2 =3D fun ts -> let l1 =3D p1 ts in let l2 =3D List.map (fun (v1,ts1) -> p2 ts1) l1 in List.concat (List.map2 (fun (v1,ts1) l2 -> List.map (fun (v2,ts2) -> combine v1 v2,ts2) l2) l1 l2) As you can see, extending this style to pThen3 & pThen4 is going to be very, very ugly (and hard to get right first time). I know it's just shorthand for map/filter, (and more complex derivatives of these), but it would be nice to have in ocaml... BTW: any suggestions on a better way to write the above function would be appreciated ;-) Kindest Regards, Jonathan Roewen