feat: add Std::Fmt — string formatting module
- C runtime: bux_float_to_string() for float64 → String conversion
- String.bux: add String_FromFloat, extern decl for bux_float_to_string
- library/std/Fmt.bux: Fmt_Fmt1, Fmt_Fmt2, Fmt_Fmt3, Fmt_FmtInt, Fmt_FmtInt2,
Fmt_FmtFloat, Fmt_FmtBool — positional {0}, {1}, {2} placeholders
- Refactor examples to use Fmt:
factorial.bux, fibonacci.bux, process.bux, os_time.bux
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Factorial - Recursive function
|
||||
import Std::Io::{PrintLine, PrintInt};
|
||||
|
||||
import Std::Io::{PrintLine};
|
||||
import Std::Fmt::{Fmt_Fmt2};
|
||||
|
||||
func Factorial(n: int) -> int {
|
||||
if n <= 1 {
|
||||
@@ -15,10 +15,7 @@ func Main() -> int {
|
||||
var i: int = 1;
|
||||
while i <= 10 {
|
||||
let fact: int = Factorial(i);
|
||||
PrintInt(i);
|
||||
PrintLine("! = ");
|
||||
PrintInt(fact);
|
||||
PrintLine("");
|
||||
PrintLine(Fmt_Fmt2("{0}! = {1}", String_FromInt(i), String_FromInt(fact)));
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user