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 JAA14821; Tue, 24 Aug 2004 09:43:16 +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 JAA15870 for ; Tue, 24 Aug 2004 09:43:15 +0200 (MET DST) Received: from qrnik.knm.org.pl (paf87.warszawa.sdi.tpnet.pl [217.96.225.87]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7O7hCmL006645 for ; Tue, 24 Aug 2004 09:43:14 +0200 Received: from qrnik ([192.168.0.1] ident=qrczak) by qrnik.knm.org.pl with esmtp (Exim 3.36 #1) id 1BzVxX-0006po-00 for caml-list@pauillac.inria.fr; Tue, 24 Aug 2004 09:43:11 +0200 Subject: Re: [Caml-list] Q: Correct locations for macro camlp4 extensions From: "Marcin 'Qrczak' Kowalczyk" To: caml-list@pauillac.inria.fr In-Reply-To: References: <1093281685.412a2795efb43@webmail.fas.harvard.edu> <20040823182936.GA8152@annexia.org> Content-Type: text/plain; charset=ISO-8859-2 Date: Tue, 24 Aug 2004 09:43:11 +0200 Message-Id: <1093333391.8623.44.camel@qrnik> Mime-Version: 1.0 X-Mailer: Evolution 1.5.9.2 Content-Transfer-Encoding: quoted-printable X-Miltered: at nez-perce with ID 412AF190.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 camlp:01 marcin:01 'qrczak':01 kowalczyk:01 qrczak:01 0400,:01 sourceforge:01 marcin:01 kowalczyk:01 qrczak:01 alexander:01 knm:01 knm:01 syntax:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk W li=B6cie z pon, 23-08-2004, godz. 19:16 -0400, Michael Alexander Hamburg napisa=B3: > Another syntax construction that I might write up (which I'm not aware of > in any programming language) would be something like >=20 > (f _ x _ _ y) translates into (fun p1 p2 p3 -> f p1 x p2 p3 y) My language Kogut uses this (along with _ in patterns as in other functional languages). Note: these expressions are evaluated once, not each time the function is applied. http://kokogut.sourceforge.net/kogut.html > When I have n lists of pairs to sort by the > first element of the tuple, or some other function like that, it saves me > a significant amount of programming effort to write >=20 > # let (<-<<) f g a b =3D f (g a) (g b);; > or > # let sort_by g a b =3D sort (compare (g a) (g b));; It may be better to perform Schwartzian transform: make a list of (g x, x) pairs, sort it, and extract elements back. It applies g O(N) rather than O(N log N) times. Well, unless g is as simple as fst. --=20 __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/ ------------------- 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