rust/src/test/run-pass/tail-cps.rs
Graydon Hoare d08b443fff Revert "Use different syntax for checks that matter to typestate"
This reverts commit aa25f22f197682de3b18fc4c8ba068d1feda220f. It broke stage2, not sure why yet.
2011-05-02 17:35:33 -07:00

35 lines
436 B
Rust

// -*- rust -*-
fn checktrue(bool res) -> bool {
check(res);
ret true;
}
fn main() {
auto k = checktrue;
evenk(42, k);
oddk(45, k);
}
fn evenk(int n, fn(bool) -> bool k) -> bool {
log "evenk";
log n;
if (n == 0) {
be k(true);
}
else {
be oddk(n - 1, k);
}
}
fn oddk(int n, fn(bool) -> bool k) -> bool {
log "oddk";
log n;
if (n == 0) {
be k(false);
}
else {
be evenk(n - 1, k);
}
}