2011-08-23 20:25:50 -05:00
|
|
|
pure fn even(x: uint) -> bool {
|
2011-07-27 07:19:39 -05:00
|
|
|
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-12-22 19:53:53 -06:00
|
|
|
fn print_even(x: uint) : even(x) { log(debug, 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); }
|