bolt/stdlib/math.bolt
2020-05-24 21:35:42 +02:00

36 lines
474 B
Text

pub struct i32;
pub struct i64;
pub struct isize;
pub struct u32;
pub struct u64;
pub struct usize;
trait Num;
fn (a: N) + (b: N) -> N where N: Num {
N::add(a, b)
}
fn (a: N) - (b: N) -> N where N: Num {
N::sub(a, b)
}
fn (a: N) / (b: N) -> N where N: Num {
N::div(a, b)
}
fn (a: N) * (b: N) -> N where N: Num {
N::mul(a, b)
}
// precedence a + b < a * b;
pub fn fac(n: I) -> I where I: int {
if n == 0 {
return 1
} else {
return fac(n-1)
}
}