import std::io; trait Show { def show(&this): i64; } def i64::show(&this): i64 { return this * 10; } def bool::show(&this): i64 { return this == true ? 1 : 0; } def total(args: Ts...): i64 where Ts...: Show { var t: i64 = 0; for const x in args { t += x.show(); } return t; } def count(args: Ts...): u64 { return args.length; } def known(args: Ts...): i64 { var t: i64 = 0; for const x in args { continue if const !(x is Show); t += 1; } return t; } def pair(args: Ts...): i64 where Ts...: integer { return (args[0] + args[1]) as i64; } def forward(args: Ts...): i64 where Ts...: Show { return total(...args); } def add3(a: i64, b: i64, c: i64): i64 { return a + b + c; } def spread(args: Ts...): i64 { return add3(...args); } def sum(first: T, rest: Ts...): T where T: numeric where Ts...: numeric { return first if const rest.length == 0; return first + sum(...rest) as T; } def until(args: Ts...): u64 { var n: u64 = 0; for const x in args { break if const !(x is Show); n++; } return n; } def bump(args: Ts...): i64 where Ts...: integer { for const x in args { x += 1; } return args[0] as i64; } const three := count(1, 2, 3); def main(): void { println($"{total(1, true, 2)} {count()} {three} {known(1, 2.5, true)} {pair(3, 4)}"); println($"{forward(5, false)} {spread(1, 2, 3)} {sum(1, 2, 3.5)} {until(1, true, 2.5, 3)} {bump(9)}"); }