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
- A .ml script runs top to bottom;
let () =sequences the printing. ^concatenates strings;print_endlinewrites one line.Printf.printfformats with compile-checked specifiers.
Keywords and builtins used here
let
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.
Step 1 of 3 in Values, step 1 of 29 in Language basics.