Okay, I tried to post this a couple of days ago, but it didn't seem to
work. Here's the five-minute Caml lesson.

First, function definition: function bindings are introduced with a
'let' construct:

let add a b c = a + b + c

To call a function, you do this:

add 3 5 7
- : int = 15

Note that there are no parentheses -- simple juxtaposition will
do. Like all functional languages, Caml supports nested and
first-class functions, and uses tail-recursion to do looping.

let fib n =
let rec loop i a b =
if i = 0 then
a
else
loop (i-1) b (a+b)
in
loop n 1 1

fib 6
- : int = 13


Now, since Caml is functional, by default variables are immutable, and
can't be mutated. As a result, if you want a mutable variable, you need
to use a reference:

let x = ref 3
val x : int ref = {contents=3}

!x (* Dereference x *)
- : int = 3

x := !x + 3 (* Increment the value inside x *)

!x
- : int = 6


Now we come to one of the annoying redundancies in Ocaml syntax. The
':=' notation is not the only way to write mutation. When you have
records with mutable fields, then you can use the '<-' notation for
mutation as well:

type foo = {mutable bar: int}

let x = {bar = 6}

x.bar
- : int = 6

x.bar <- x.bar - 3 (* The record field is mutated *)

x.bar
- : int = 3

Now, the quick and dirty object tutorial. Here's a simple class

class foo =
object
val mutable x = 0 (* A mutable instance variable *)

method get_x = x (* A getter for the instance var x *)
end

let obj = new foo

obj#get_x (* Method call uses '#' instead of '.' *)

You can add arguments to the initalizer like so:

class point u v =
object
val mutable x = u
val mutable y = v

method get_x = x
method get_y = y

method move dx dy =
begin
x <- x + dx;
y <- y + dy;
end
end

let pt = new point 3 5

pt#get_x
- : int = 3

pt#move 4 5

(pt#get_x, pt#get_y)
- : int * int = 7, 10