From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 7AE6FBC0A for ; Sat, 23 Dec 2006 15:48:21 +0100 (CET) Received: from NS1.home (74.220-119-85.cust.rackboost.net [85.119.220.74]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBNEmKt3020214 for ; Sat, 23 Dec 2006 15:48:21 +0100 Received: from [192.168.0.192] ([87.235.198.48]) by home with MailEnable ESMTP; Sat, 23 Dec 2006 15:48:28 +0100 Subject: The Map and Fold From: lloydmoore To: caml-list@yquem.inria.fr Content-Type: text/plain Date: Sat, 23 Dec 2006 15:48:21 +0000 Message-Id: <1166888901.18736.9.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 458D41B5.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; stl:01 functions:01 'on:96 vector:05 accumulator:05 iterate:06 fold:06 fold:06 entity:06 indeed:07 arguments:07 function:08 sense:10 opposed:11 perform:11 In reply to the relationship between map and fold, The fold difference is that only a single entity is returned (the accumulator) as opposed to, if you like, a place for each original array/list/vector member. Fold is indeed an extended specialized version of map because it has to perform both functions... iterate over the elements and use them as function arguments but it then goes one step further and accumulates the results as it iterates. Using STL, this would be the difference between mapping a X.t into b X.t and stopping there, or going the extra step and summising your new set of results 'on the fly' as it were. Hope this makes sense :D http://www.encantado.net