Jump to content

Category talk:Wren-fmt: Difference between revisions

m
→‎Source code: Removed some surplus whitespace.
(→‎Source code: Several improvements including support for formatting a sequence of values.)
m (→‎Source code: Removed some surplus whitespace.)
Line 259:
}
if (len == 0) return (v is String) ? v : "%(v)"
if (len == 1) cc = cc + cc
return "%(cc[0])%(v)%(cc[1])"
}
 
// Convenience version of the above which uses double quotes as the embedding characters.
static q(v) { "\"%(v)\"" }
 
// 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 331:
 
// Works like 'fc' except replaces any trailing zeros after the decimal point with spaces.
// If the resulting string would end with a decimal point, a zero is first added back.
static gc(w, n, p) {
var f = fc(w, n, p)
Line 381:
(fn == "dp") ? dp(w, e) :
(fn == "dm") ? dm(w, e) :
(fn == "dc") ? dc(w, e) :
(fn == "fc") ? fc(w, e, p) :
(gn == "gc") ? gc(w, e, p) : Fiber.abort("Method not recognized.")
l[i] = q(l[i], cc)
}
return q(l.join(sep), bb)
}
 
Line 393:
static v(fn, w, seq, p, sep, bb) { v(fn, w, seq, p, sep, bb, "") }
static v(fn, w, seq, p) { v(fn, w, seq, p, ", ", "[]", "") }
static v(fn, w, seq) { v(fn, w, seq, precision, ", ", "[]", "") }
}
 
9,485

edits

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