English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: Teaching bottomline, part 3: what should improve.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

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