Skip to content

Instantly share code, notes, and snippets.

@b-studios
Created November 7, 2017 09:57
Show Gist options
  • Save b-studios/a313610f05db169e146104e197e5802e to your computer and use it in GitHub Desktop.
Save b-studios/a313610f05db169e146104e197e5802e to your computer and use it in GitHub Desktop.
Challenge to compile using iterated CPS
effect exc {
raise(n: int): a;
}
val inc = handler {
raise(n) -> raise(n + 1)
}
val get = handler {
raise(n) -> n
}
fun f(n) {
if (n <= 0) {
raise(n)
} else {
inc({ f(n - 1) })
}
}
// run with
get({ f(10) })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment