Created
October 7, 2018 10:42
-
-
Save dbrattli/dfabab0a61dd69d0ca44217855e776e3 to your computer and use it in GitHub Desktop.
Pythagoras CPS
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 addCps a b cont : unit = | |
cont (a + b) | |
let squareCps x cont : unit = | |
cont (x * x) | |
let sqrtCps x cont : unit = | |
cont (sqrt x) | |
// Pythagoras rewritten in CPS | |
let pythagorasCps a b cont : unit = | |
squareCps a (fun aa -> | |
squareCps b (fun bb -> | |
addCps aa bb (fun aabb -> | |
sqrtCps aabb (fun result -> | |
cont result) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment