OCaml By Examples

lists

main.ml

Lists can hold any number of items of the same type.
open Core

let () = 
The items are separated by semicolons.
  let a = [1; 2; 3] in
  let b = a @ [4] in 
  let c = 0 :: b in 
  List.iter c ~f:(fun i -> printf "%d\n" i)
  

console

Items can be prepended and appended to lists
$ dune exec ./main.exe
0
1
Lists can be iterated over and displayed.
2
3
4
next: sets