Skip to content

Instantly share code, notes, and snippets.

@mitsuji
Created June 19, 2022 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitsuji/d79e91a61578199e6be7df085b272772 to your computer and use it in GitHub Desktop.
Save mitsuji/d79e91a61578199e6be7df085b272772 to your computer and use it in GitHub Desktop.
Expected Value in koka
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