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
Experiences with learning OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-11-25 (13:47)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Experiences with learning OCaml?
On Thu, 2004-11-25 at 22:59, Erik de Castro Lopo wrote:

> > Would doing this be difficult if one were sufficiently motivated? 
> If you are reasonably familiar with languages as complex as C++ and
> Java, then Ocaml is definitely not too difficult but will require 
> you to develope some new ways of thinking about programming problems.

Functional programming is easy. There's a whole lot of
fuss about something simple.. :)

let decade = 
  let k = 10 in
  map (fun i -> i * k) [1;2;3;4]

I'm sure you'll understand the answer is 
the list of integers [10,20,30,40] once you grok the syntax,
and that example contains a higher order function map
(a function accepting a function as an argument) and
a lexically scoped anonymous function (fun i -> i * k)
which binds to the 'k' in scope. .. but these are just
features 'you always wanted in C++ anyhow' and got
sick of writing lame workarounds for ... :)

Once you have these features, your style of programming
will change naturally, even though Ocaml also has classes,
object, mutable varables, and imperative constructions too.

> Ocaml is a good choice.

Yes, because you can have quite a bit of fun solving
problems 'the usual imperative way' and then trying
to make it simpler.. which you'll find functional programming
helps with a lot.

John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net