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 DE9CEBB84 for ; Sun, 16 Apr 2006 23:12:09 +0200 (CEST) Received: from out3.smtp.messagingengine.com (out3.smtp.messagingengine.com [66.111.4.27]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k3GLC91Z023384 for ; Sun, 16 Apr 2006 23:12:09 +0200 Received: from frontend2.internal (frontend2.internal [10.202.2.151]) by frontend1.messagingengine.com (Postfix) with ESMTP id 39985D4C7B0 for ; Sun, 16 Apr 2006 17:12:07 -0400 (EDT) Received: from web2.messagingengine.com ([10.202.2.211]) by frontend2.internal (MEProxy); Sun, 16 Apr 2006 17:11:38 -0400 Received: by web2.messagingengine.com (Postfix, from userid 99) id 4FC31F1BD; Sun, 16 Apr 2006 17:11:38 -0400 (EDT) Message-Id: <1145221898.16349.259200911@webmail.messagingengine.com> X-Sasl-Enc: 8qTYc3r5i3yroDcK8AinRjZ7TpolkTUJsvCXFFEOiLm4 1145221898 From: "Tato Thetza" To: caml-list@yquem.inria.fr Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="ISO-8859-1" MIME-Version: 1.0 X-Mailer: MIME::Lite 5022 (F2.72; T1.15; A1.62; B3.04; Q3.03) Subject: recursion/iterator question Date: Sun, 16 Apr 2006 14:11:38 -0700 X-Miltered: at concorde with ID 4442B329.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; recursion:01 iterator:01 uncommon:01 caml-list:01 expressions:04 iterate:06 iterate:06 cleaner:07 function:08 example:10 question:11 think:11 create:12 such:14 set:14 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DNS_FROM_RFC_ABUSE autolearn=disabled version=3.0.3 Hi caml-list Given a list, I would like to iterate over all triplets in the list. For example, in mathematcs, its not uncommon to have expressions such as "for all i,j,k in set X, do f(i,j,k)" The only way I can think of is to create a list with all triplets of the list, so: triplets([1,2,3,4]) = [(1,2,3),(1,2,4),(1,3,4),(2,3,4)] and take this list and map a function f to it. questions: 1) what would be the best way to write triplets? 2) is there a cleaner way to iterate over all triplets in a list? please excuse my english Tato T.