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=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 59E99BC0A for ; Fri, 22 Dec 2006 12:19:05 +0100 (CET) Received: from ipmail02.adl2.internode.on.net (ipmail02.adl2.internode.on.net [203.16.214.141]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBMBJ31T013550 for ; Fri, 22 Dec 2006 12:19:04 +0100 Received: from ppp14-213.lns2.syd7.internode.on.net (HELO rosella) ([59.167.14.213]) by ipmail02.adl2.internode.on.net with ESMTP; 22 Dec 2006 21:48:11 +1030 X-IronPort-AV: i="4.12,204,1165152600"; d="scan'208"; a="63696522:sNHT110638794" Subject: map and fold From: skaller To: caml-list@yquem.inria.fr Content-Type: text/plain Date: Fri, 22 Dec 2006 22:18:06 +1100 Message-Id: <1166786286.6549.24.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 458BBF27.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; stl:01 iterator:01 iterator:01 sourceforge:01 constructor:01 constructor:01 algorithm:01 define:01 hmm:02 output:02 seems:03 element:03 element:03 hint:04 fold:06 What is the relationship between map and fold? It seems like if you have a X.fold plus an constructor which adds an element to an existing container Y.t you can define a kind of map which copies elements of 'a X.t into 'b T.t given an element map f: 'a -> 'b. In STL the algorithm accumulate can do this, given a start and end iterator for the input container, and an insert iterator for the output container. Anyhow it 'feels' like the fold is a container destructor, and the constructor is a kind of 'dual' of fold. Map is then just a combination of the fold with a special case of the constructor function.. hmm. Any hint what the formal symmetry is here? -- John Skaller Felix, successor to C++: http://felix.sf.net