Created
July 3, 2017 15:32
-
-
Save Richard-Degenne/ce2c83730d22133370d7588af2dde908 to your computer and use it in GitHub Desktop.
OCaml functional update example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type coordinates = {x: int; y: int} (* Define a record type for coordinates *) | |
type player = {name: string; coordinates: coordinates} (* Define a record type for players *) | |
let richou = {name = "Richou"; coordinates = {x=0; y=0}} (* Define a new player *) | |
(* This is called a functional update. | |
* It creates a new record "based on" an existing record. | |
*) | |
let richou2 = {richou with coordinates = {x=1; y=1}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment