Category talk:Wren-fmt: Difference between revisions

→‎Source code: Added 'yes/no' format.
(→‎Source code: Added 'repeat' format.)
(→‎Source code: Added 'yes/no' format.)
Line 367:
// Convenience version of the above which uses double quotes as the embedding characters.
static q(v) { "\"%(v)\"" }
 
// Maps the boolean value 'b' to "yes" if true or "no" if false
// and then applies the 's' format to the result.
static y(w, b) { Fmt.s(w, b ? "yes" : "no") }
 
// Formats a number 'n' (using 'h' format) to a maximum precision of 14 decimal places.
Line 626 ⟶ 630:
(fn == "u") ? u(w, v) :
(fn == "q") ? q(v) :
(fn == "y") ? y(w, v) :
(fn == "e") ? e(w, v, p) :
(fn == "E") ? Fmt.E(w, v, p) :
Line 752 ⟶ 757:
// $[flag][width][.precision][letter] of which all bracketed items except [letter] are optional.
// The letter must be one of the 'short' methods:
// a, b, c, d, e, E, f, F, g, h, i, I, j, k, l, m, n, N, o, O, P, q, r, R, s, S, t, u, x, X, y or z.
// If present, the flag (there can only be one) must be one of the following:
// + always prints a + or - sign ('dp', 'fp', 'gp' or 'hp' methods)
Line 822 ⟶ 827:
var fn = ""
var ds = ""
if ("abcdeEfFghiIjklmnNoOPqrRsStuxXzabcdeEfFghiIjklmnNoOPqrRsStuxXyz".codePoints.contains(cp)) { // format letter
fn = Conv.itoc(cp)
} else if (cp == 42) { // star
Line 857 ⟶ 862:
 
if (fn == "") {
if (!"abcdeEfFghiIjklmnNoOPqrRsStuxXzabcdeEfFghiIjklmnNoOPqrRsStuxXyz".codePoints.contains(cp)) {
Fiber.abort("Unrecognized character in format string.")
}
9,476

edits