Created
October 8, 2019 23:54
-
-
Save patricoferris/cd22b3482b6b03b1377b081c6cd74367 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
(* A fibonacci function *) | |
let rec fib x = if x = 0 || x = 1 then 1 else fib (x - 1) + fib (x - 2);; | |
(* A function that allows for partial evaluation *) | |
let h x = let z = fib x in fun y -> y + z;; | |
(* fib 30 will only be calculated once *) | |
List.map (h 30) [1; 2; 3; 4; 5];; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment