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 2A621BC0A for ; Thu, 24 May 2007 18:31:03 +0200 (CEST) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.249]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4OGV1gP011947 for ; Thu, 24 May 2007 18:31:02 +0200 Received: by an-out-0708.google.com with SMTP id b15so84276ana for ; Thu, 24 May 2007 09:30:57 -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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=aFuhXFh3Ez2NzznLXlyWWN7PvGyC59vuC4/lDK0a5LZijWXFefBZGxijmg6qrhPbJ95zsp5rrSGrlzdShuBZBSP6OkzrdklK/Eq9URPcelYGoB5nyN9rst2zTl0t9+mDeiilq4DO36g6VqcEv1E7Zd7kM4vkYwMc0asS8ufFHF8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=lHfRNLvmi9FzQ4t0uJExra7plHcjGnwaHVIP7Y2XayxJubOl2538/bvDqppV4qpeaacOv5lALnfhQqaeMkhvyYrEqa6RgARxU734mNLi47lb0KrSZg8KuhepJa2oVVgxC7I3mevTzOqGeLpf87XK9OSKLlUdrPJEkcQUYiOvT8E= Received: by 10.100.210.10 with SMTP id i10mr1719271ang.1180024256980; Thu, 24 May 2007 09:30:56 -0700 (PDT) Received: by 10.100.168.16 with HTTP; Thu, 24 May 2007 09:30:56 -0700 (PDT) Message-ID: <6f9f8f4a0705240930t612a7ea9n725c42cbceb864f1@mail.gmail.com> Date: Thu, 24 May 2007 18:30:56 +0200 From: "Loup Vaillant" To: "David Teller" Subject: Re: [Caml-list] Re: Teaching bottomline, part 3: what should improve. Cc: caml-list@yquem.inria.fr In-Reply-To: <1179924683.6966.90.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> X-j-chkmail-Score: MSGID : 4655BDC5.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 4655BDC5.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ens-lyon:01 0200,:01 integers:01 syntax:01 semantics:01 arrays:01 haskell:01 syntax:01 camlp:01 23,:98 2007,:98 wrote:01 wrote:01 caml-list:01 functions:01 2007/5/23, David Teller : > On Wed, 2007-05-23 at 10:03 +0200, Loup Vaillant wrote: > > On Tue, 22 May 2007, David Teller wrote: > > > > > * That's not OCaml-specific but there must be some construction better [...] > > What about map fold, filter, and the like? Sure, they are somewhat [...] > > I was thinking about a fold specialised in integers. But with a "better" > syntax and semantics than either fold (i.e. no anonymous functions) or > for (i.e. no reliance on references). Of course, I don't have such a > construction at hand. It sounds like you need some kind of macro which can encapsulate a chunk of code into an anonymous function like : for_each i : my_list begin i*2 end (* map (fun i -> i*2) my_list *) and : accumulate acc = 0 in i : my_list begin acc+i end (* fold (+) 0 my_list *) Problem : works only on lists (or arrays, depending of your choice). And a Haskell like syntax for creating lists would help. (something like [0..10]). I think camlp4 can handle all that. Another solution to your problem is to use a Lisp syntax, and write the appropriate macros (and go explain what a macro is...). :) > > > * Some students rely too much on references. > > > > If they are used to for and while loops, they will think more often in > > terms of references (as I did). Then, we have the array, a collection > > of references. Do you think your students could learn some purely > > functional data structures instead? Should they? > > There is such a thing as relying *too much* on references. Ah. Well, are they sometimes incapable of solving a problem in a pure functional way? Is it just harder? By the way, for how long have they been exposed to imperative languages before your course? regards, Loup