2011-07-27 07:19:39 -05:00
|
|
|
pred even(x: uint) -> bool {
|
|
|
|
if x < 2u {
|
|
|
|
ret false;
|
2011-08-19 17:16:48 -05:00
|
|
|
} else if x == 2u { ret true; } else { ret even(x - 2u); }
|
2011-06-17 21:07:23 -05:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:48:34 -05:00
|
|
|
fn print_even(x: uint) : even(x) { log x; }
|
2011-06-17 21:07:23 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn foo(x: uint) { if check even(x) { print_even(x); } else { fail; } }
|
2011-06-17 21:07:23 -05:00
|
|
|
|
2011-08-19 17:16:48 -05:00
|
|
|
fn main() { foo(2u); }
|