92c5cd59f5
- Create stdlib/Std/Io.bux with extern func declarations
- Rename C shim functions to short names (PrintLine, PrintInt, etc.)
- Update all 9 examples to use import Std::Io::{PrintLine, PrintInt};
- Remove manual extern func Std_Io_* declarations from examples
27 lines
449 B
Plaintext
27 lines
449 B
Plaintext
// Generics - Generic functions and structs
|
|
import Std::Io::{PrintLine, PrintInt};
|
|
|
|
|
|
func Max<T>(a: T, b: T) -> T {
|
|
if a > b {
|
|
return a;
|
|
} else {
|
|
return b;
|
|
}
|
|
}
|
|
|
|
func Main() -> int {
|
|
let m1: int = Max<int>(10, 20);
|
|
let m2: int = Max<int>(5, 3);
|
|
|
|
PrintLine("Max(10, 20) = ");
|
|
PrintInt(m1);
|
|
PrintLine("");
|
|
|
|
PrintLine("Max(5, 3) = ");
|
|
PrintInt(m2);
|
|
PrintLine("");
|
|
|
|
return 0;
|
|
}
|