September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,15 @@
def pp0(width):
tostring
| if width > length then (width - length) * "0" + . else . end;
# pp(left; right) formats a decimal number to occupy
# (left+right+1) positions if possible,
# where "left" is the number of characters to the left of
# the decimal point, and similarly for "right".
def pp(left; right):
def lpad: if (left > length) then ((left - length) * "0") + . else . end;
tostring as $s
| $s
| index(".") as $ix
| ((if $ix then $s[0:$ix] else $s end) | lpad) + "." +
(if $ix then $s[$ix+1:] | .[0:right] else "" end);

View file

@ -0,0 +1 @@
(1.0, 12.3, 333.333, 1e6) | pp0(10)

View file

@ -0,0 +1,4 @@
0000000001
00000012.3
000333.333
0001000000

View file

@ -0,0 +1 @@
(1.0, 12.3, 333.333, 1e6) | pp(4;2)

View file

@ -0,0 +1,4 @@
0001.
0012.3
0333.33
1000000.