Probabilistic choice: Difference between revisions
→{{header|jq}}: simplify align_decimal
(→{{header|jq}}: simplify align_decimal) |
|||
Line 2,047:
def rpad($len): tostring | ($len - length) as $l | .+ ("0" * $l)[:$l];
# Input: a string of digits with up to one
# Output: the corresponding string representation with exactly $n decimal digits
def align_decimal($n):
tostring
Line 2,054:
| if $ix then capture("(?<i>[0-9]*[.])(?<j>[0-9]{0," + ($n|tostring) + "})") as {$i, $j}
| $i + ($j|rpad($n))
else . + ".
end ;
Line 2,153:
heth : 63455.9 63348 0.18
</pre>
=={{header|Julia}}==
|