summary refs log tree commit diff
path: root/src/test/run-pass/tail-cps.rs
blob: 725ac36fbc834f727b6f772e2cb753230476420e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



// -*- rust -*-
fn checktrue(rs: bool) -> bool { assert (rs); ret true; }

fn main() { let k = checktrue; evenk(42, k); oddk(45, k); }

fn evenk(n: int, k: native fn(bool) -> bool) -> bool {
    #debug("evenk");
    log(debug, n);
    if n == 0 { be k(true); } else { be oddk(n - 1, k); }
}

fn oddk(n: int, k: native fn(bool) -> bool) -> bool {
    #debug("oddk");
    log(debug, n);
    if n == 0 { be k(false); } else { be evenk(n - 1, k); }
}