Last active
January 3, 2016 02:09
-
-
Save hkoba/8393373 to your computer and use it in GitHub Desktop.
Perl's '//' operator in OCaml, but this is type-safe.
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
let (//) optional default = | |
match optional with | |
| None -> default | |
| Some x -> x | |
(* You can use this like: | |
(Map.find t s // 0) + 1 | |
*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment