Created
January 20, 2014 02:37
-
-
Save cohalz/8514017 to your computer and use it in GitHub Desktop.
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 rec pow n x = | |
if n <= 1 then x | |
else let stack = pow (n/2) x in | |
if n mod 2 = 0 then stack*stack | |
else x*stack*stack | |
let cube x = pow 3 x | |
let rec pow2 x n = | |
if n <= 1 then x | |
else let stack = pow2 x (n/2) in | |
if n mod 2 = 0 then stack*stack | |
else x*stack*stack | |
let cube2 x = pow2 x 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment