Browse thread
Re: Teaching bottomline, part 3: what should improve.
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Loup Vaillant <loup.vaillant@g...> |
| Subject: | Re: [Caml-list] Re: Teaching bottomline, part 3: what should improve. |
2007/5/23, David Teller <David.Teller@ens-lyon.org>: > 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