Files
Basalt2/node_modules/shiki/samples/ocaml.sample
Robert Jelic 31787b0e9b Fix
2025-02-16 18:04:24 +01:00

24 lines
734 B
Plaintext

utop # type person = { name: string ; age: int ; human : bool };;
type person = { name : string; age : int; human : bool; }
utop # let david = { name = "david" ; age = 32 ; human = false };;
val david : person = {name = "david"; age = 32; human = false}
utop # let mary = { david with name = "mary" };;
val mary : person = {name = "mary"; age = 32; human = false}
utop # let toggle_human (p : person) = { p with human = not p.human };;
val toggle_human : person -> person = <fun>
utop # let () =
let david' = toggle_human david in
if david'.human then
print_endline "david is human"
else
print_endline "david is not human"
;;
david is human
(** From https://o1-labs.github.io/ocamlbyexample/basics-records.html *)