typestar

The script shape in OCaml

The smallest OCaml: let bindings and a let () = of effects.

(* A script runs top to bottom; let () = sequences the effects. *)
let shore = "Gull Point"
let pools = 6

let () =
  print_endline ("Low tide survey at " ^ shore);
  Printf.printf "Pools to sample: %d\n" pools;
  Printf.printf "Quadrats if all open: %d\n" (pools * 4)

How it works

  1. A .ml script runs top to bottom; let () = sequences the printing.
  2. ^ concatenates strings; print_endline writes one line.
  3. Printf.printf formats with compile-checked specifiers.

Keywords and builtins used here

The run, in numbers

Lines
8
Characters to type
262
Tokens
49
Three-star pace
70 tpm

At the three-star pace of 70 tokens a minute, this run takes about 42 seconds.

Type this snippet

Step 1 of 3 in Values, step 1 of 29 in Language basics.

Next →

The script shape in other languages