Created
January 18, 2016 03:42
-
-
Save matthewhammer/903b6f909a0a12445e71 to your computer and use it in GitHub Desktop.
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
(* Doubly linked list node *) | |
type 'a dlln = { mutable data : 'a ; | |
mutable prev : 'a dlln ; | |
mutable next : 'a dlln } | |
(* Look ma, a cycle can be initialized without any NULL pointers! *) | |
let rec singleton : int dlln = | |
{ data = 0 ; | |
prev = singleton ; | |
next = singleton } | |
;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The fields are mutable so that it's morally closer to C. In OCaml, such definitions require no laziness, implicit or explicit. No function abstractions/applications are required.