3 fn add(x: int, y: int) -> int { ret x + y; }
5 fn sub(x: int, y: int) -> int { ret x - y; }
7 fn mul(x: int, y: int) -> int { ret x * y; }
9 fn div(x: int, y: int) -> int { ret x / y; }
11 fn rem(x: int, y: int) -> int { ret x % y; }
13 fn lt(x: int, y: int) -> bool { ret x < y; }
15 fn le(x: int, y: int) -> bool { ret x <= y; }
17 fn eq(x: int, y: int) -> bool { ret x == y; }
19 fn ne(x: int, y: int) -> bool { ret x != y; }
21 fn ge(x: int, y: int) -> bool { ret x >= y; }
23 fn gt(x: int, y: int) -> bool { ret x > y; }
25 fn positive(x: int) -> bool { ret x > 0; }
27 fn negative(x: int) -> bool { ret x < 0; }
29 fn nonpositive(x: int) -> bool { ret x <= 0; }
31 fn nonnegative(x: int) -> bool { ret x >= 0; }
34 // FIXME: Make sure this works with negative integers.
35 fn hash(x: &int) -> uint { ret x as uint; }
37 fn eq_alias(x: &int, y: &int) -> bool { ret x == y; }
39 iter range(lo: int, hi: int) -> int {
41 while lo_ < hi { put lo_; lo_ += 1; }
44 fn to_str(n: int, radix: uint) -> str {
45 assert (0u < radix && radix <= 16u);
47 "-" + istr::to_estr(uint::to_str(-n as uint, radix))
48 } else { istr::to_estr(uint::to_str(n as uint, radix)) };
50 fn str(i: int) -> str { ret to_str(i, 10u); }
52 fn pow(base: int, exponent: uint) -> int {
53 ret if exponent == 0u {
60 while count > 1u { accum *= base; count -= 1u; }
67 // indent-tabs-mode: nil
69 // buffer-file-coding-system: utf-8-unix
70 // compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";