Jump to content

Category talk:Wren-fmt: Difference between revisions

→‎Source code: Added 'repeat' format.
m (→‎Source code: Change to comment.)
(→‎Source code: Added 'repeat' format.)
Line 421:
// two or three element list. Forms the plural by just adding "s" to l[1] if 'l' is a two element list.
static P(w, l) { s(w, Conv.plural(l[0], l[1], l.count == 2 ? l[1] + "s" : l[2])) }
 
// Repeats 'v', a string or value, 'n' times.
static R(n, v) { (v is String) ? v * n : v.toString * n }
 
// Pads a number 'n' with leading spaces to a minimum width 'w' and a precision of 'p' decimal places.
// Precision is restricted to 14 places though entering a higher figure is not an error.
Line 631 ⟶ 634:
(fn == "F") ? Fmt.F(w, v) :
(fn == "P") ? Fmt.P(w, v) :
(fn == "R") ? Fmt.R(w, v) :
(fn == "f") ? f(w, v, p) :
(fn == "g") ? g(w, v, p) :
Line 748 ⟶ 752:
// $[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 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 818 ⟶ 822:
var fn = ""
var ds = ""
if ("abcdeEfFghiIjklmnNoOPqrsStuxXzabcdeEfFghiIjklmnNoOPqrRsStuxXz".codePoints.contains(cp)) { // format letter
fn = Conv.itoc(cp)
} else if (cp == 42) { // star
Line 853 ⟶ 857:
 
if (fn == "") {
if (!"abcdeEfFghiIjklmnNoOPqrsStuxXzabcdeEfFghiIjklmnNoOPqrRsStuxXz".codePoints.contains(cp)) {
Fiber.abort("Unrecognized character in format string.")
}
Line 882 ⟶ 886:
if (next < a.count) {
var e = a[next]
if ((e is Sequence) && !(e is String) && !"nuFPnuFPR".contains(fn)) {
if (hash && "btodxX".contains(fn[0])) {
var rr = []
9,485

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.