Created
October 6, 2015 21:22
-
-
Save Isweet/102d2150f0dbde7333b1 to your computer and use it in GitHub Desktop.
Functions as values in OCaml
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 comp = fun f -> (fun g -> (fun x -> f (g x)));; | |
let doublesquare = comp (fun x -> x + x) (fun y -> y * y);; | |
print_int (doublesquare 5); print_newline ();; | |
(* expect 50 *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment