Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Loup Vaillant <loup.vaillant@g...>
Subject: Re: [Caml-list] Re: Teaching bottomline, part 3: what should improve.
On Tue, 22 May 2007, David Teller wrote:

> * That's not OCaml-specific but there must be some construction better
> suited than "for" or "while" to write loops without having to handcode a
> recursive loops. Right now, I can't think of anything better than a
> "hidden" Y combinator, but there must be something.

What about map fold, filter, and the like? Sure, they are somewhat
specialized, but most can be rewritten for many data structures.
If you are really desperate, You can write The Recursive Loops
(terminal and not terminal, 3 lines each). But I guess you tried.


> * Arrays of arrays (of arrays...) are a bit obscure for students,
> although they're getting better at it.
>
> * 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?

> * Anonymous functions are still beyond most of them.

That sounds surprising, for anonymous function are no different from named ones:

5;; (* a value *)
fun x -> x+1;; (* another value, which happens to be a function *)

a = 5;; (* a bound value *)
b = fun x -> x+1;; (* another bound value, which happens to be a function *)

Did your students used map and fold-like functions much? These almost
require anonymous functions.

regards,
Loup Vaillant