RosettaCodeData/Task/Runge-Kutta-method/Jq/runge-kutta-method-3.jq
2023-07-01 13:44:08 -04:00

9 lines
305 B
Text

# n is the number of decimal places of precision
def round(n):
(if . < 0 then -1 else 1 end) as $s
| $s*10*.*n | if (floor % 10) > 4 then (.+5) else . end | ./10 | floor/n | .*$s;
def abs: if . < 0 then -. else . end;
# Is the input an integer?
def integerq: ((. - ((.+.01) | floor)) | abs) < 0.01;