rust/src/test/run-pass/tail-cps.rs

19 lines
413 B
Rust
Raw Normal View History

2010-06-23 23:03:09 -05:00
// -*- rust -*-
fn checktrue(bool rs) -> bool { assert (rs); ret true; }
fn main() { auto k = checktrue; evenk(42, k); oddk(45, k); }
2010-06-23 23:03:09 -05:00
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); }
2010-06-23 23:03:09 -05:00
}
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); }
}