Created
June 19, 2022 02:53
-
-
Save mitsuji/d79e91a61578199e6be7df085b272772 to your computer and use it in GitHub Desktop.
Expected Value in koka
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
effect flip | |
ctl flip () : bool | |
fun calculation () | |
if flip () then | |
val unused = flip () | |
if flip () then 0.5 | |
else 4.0 | |
else 1.0 | |
fun expected_value (f: () -> flip float64) : float64 | |
with ctl flip() | |
val x:float64 = resume(True) + resume(False) | |
x / 2.0 | |
f () | |
fun main() | |
println(expected_value(calculation)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment