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=1.0 required=5.0 tests=AWL,SPF_NEUTRAL 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 7E6B6BC0A for ; Fri, 25 May 2007 09:58:47 +0200 (CEST) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.244]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4P7wk50024350 for ; Fri, 25 May 2007 09:58:47 +0200 Received: by an-out-0708.google.com with SMTP id b15so208764ana for ; Fri, 25 May 2007 00:58:45 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Ga5/bX/Snrd4bJNA4R/qCApLI6GG4BdDuUwgq9Luug/yCvY5u819wC3DpbLty9hhwKlTSpHhdXoFCml0eutjJ/uWXxEgxG7spXEZIJsfGd9mMYG0VdUSxqauSGz0MWXAaEl34xua8Dir6VD+1gjWrEbqF08KhYm8R7Hq/eZnsck= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=kfcGcV5qz3tY27nGV7baOlYT6Chl7GQOmoUIalJMA6z3UZd1Q10VT6Dpq5+0FmRxbda+HxqZv2UiHOLRaGUWuErJzGRkRzQVcdz8kbAyxu2Ux0HrHbvcsrPvlXJ2axFgwvlWzrPrswFAtaHxzQ67JG/uxtH1ZC729FsWsIypv/M= Received: by 10.100.229.12 with SMTP id b12mr2556469anh.1180079925715; Fri, 25 May 2007 00:58:45 -0700 (PDT) Received: by 10.100.168.16 with HTTP; Fri, 25 May 2007 00:58:45 -0700 (PDT) Message-ID: <6f9f8f4a0705250058y769cb536wa95970d3fcafae23@mail.gmail.com> Date: Fri, 25 May 2007 09:58:45 +0200 From: "Loup Vaillant" To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: Teaching bottomline, part 3: what should improve. In-Reply-To: <1180042153.6098.40.camel@Blefuscu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070522234715.0BCB2BC74@yquem.inria.fr> <4653CF5C.4040305@cs.washington.edu> <6f9f8f4a0705230103r7152299esca6b56db93cfcf08@mail.gmail.com> <1179924683.6966.90.camel@Blefuscu> <6f9f8f4a0705240930t612a7ea9n725c42cbceb864f1@mail.gmail.com> <1180042153.6098.40.camel@Blefuscu> X-j-chkmail-Score: MSGID : 46569736.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46569736.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ens-lyon:01 0200,:01 traversing:01 traversing:01 syntax:01 lacked:01 syntax:01 cheers:01 wrote:01 syntactic:01 syntactic:01 caml-list:01 functions:01 computation:01 argument:02 2007/5/24, David Teller : > On Thu, 2007-05-24 at 18:30 +0200, Loup Vaillant wrote: > > It sounds like you need some kind of macro which can encapsulate a > > chunk of code into an anonymous function like : > >[...] > > Or perhaps > > map i traversing my_list > begin > i*2 > end > > accumulate acc = 0 with i traversing my_list > begin > acc+i > end > > ... Discussing of syntactic sugar, I prefer Jon's syntax : more concise, and no ugly "begin end" (I hate those, and I proposed them only because I lacked a better Idea). Another solution, no macro of any kind required : why not explain map and fold as mere syntactic constructions? Sure, such a syntax looks a bit weird, but you can then wait before explaining anything about anonymous functions. Your students could just know they have some construction to iterate over a list, some other to select some elements of a list, and some other to accumulate a list on something through a computation. When complaints arise about such an awful syntax, have them implement map, filter, and fold. You may have to make clear that the first argument is a function. Personally, I'd begin by the latter part (implementation), so the former are useless. My brother is currently in his first year in college, and he is studying Caml light. I'll try to have him implement map. cheers, Loup