2010-07-20 20:03:09 -05:00
|
|
|
import std.sys;
|
|
|
|
|
2010-06-23 23:03:09 -05:00
|
|
|
fn add(int x, int y) -> int { ret x + y; }
|
|
|
|
fn sub(int x, int y) -> int { ret x - y; }
|
|
|
|
fn mul(int x, int y) -> int { ret x * y; }
|
|
|
|
fn div(int x, int y) -> int { ret x / y; }
|
|
|
|
fn rem(int x, int y) -> int { ret x % y; }
|
|
|
|
|
|
|
|
fn lt(int x, int y) -> bool { ret x < y; }
|
|
|
|
fn le(int x, int y) -> bool { ret x <= y; }
|
|
|
|
fn eq(int x, int y) -> bool { ret x == y; }
|
|
|
|
fn ne(int x, int y) -> bool { ret x != y; }
|
|
|
|
fn ge(int x, int y) -> bool { ret x >= y; }
|
|
|
|
fn gt(int x, int y) -> bool { ret x > y; }
|
|
|
|
|
2010-08-03 19:52:35 -05:00
|
|
|
fn positive(int x) -> bool { ret x > 0; }
|
|
|
|
fn negative(int x) -> bool { ret x < 0; }
|
|
|
|
fn nonpositive(int x) -> bool { ret x <= 0; }
|
|
|
|
fn nonnegative(int x) -> bool { ret x >= 0; }
|
|
|
|
|
2010-06-23 23:03:09 -05:00
|
|
|
iter range(mutable int lo, int hi) -> int {
|
|
|
|
while (lo < hi) {
|
|
|
|
put lo;
|
|
|
|
lo += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-24 18:01:34 -05:00
|
|
|
fn to_str(mutable int n, uint radix) -> str
|
2010-08-06 17:48:23 -05:00
|
|
|
{
|
|
|
|
check (0u < radix && radix <= 16u);
|
|
|
|
if (n < 0) {
|
2010-08-20 13:40:59 -05:00
|
|
|
ret "-" + _uint.to_str((-n) as uint, radix);
|
2010-08-06 17:48:23 -05:00
|
|
|
} else {
|
2010-08-20 13:40:59 -05:00
|
|
|
ret _uint.to_str(n as uint, radix);
|
2010-08-06 17:48:23 -05:00
|
|
|
}
|
|
|
|
}
|