Created
August 17, 2014 19:03
-
-
Save ramntry/faaa524186cd804fc059 to your computer and use it in GitHub Desktop.
Call-by-name?
This file contains hidden or 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 get_incremetor = | |
| let current_defult_delta = ref 0 in | |
| let closure () = | |
| incr current_defult_delta; | |
| fun ?(delta=(int_of_string (string_of_int (!current_defult_delta)))) n -> | |
| n + delta | |
| in | |
| closure | |
| let () = | |
| let inc1 = get_incremetor () in | |
| let inc2 = get_incremetor () in | |
| let inc3 = get_incremetor () in | |
| assert (inc1 10 = 11); | |
| assert (inc2 ~delta:100 20 = 120); | |
| assert (inc3 30 = 33) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment