RosettaCodeData/Task/Euler-method/Jq/euler-method-2.jq
2017-09-25 22:28:19 +02:00

10 lines
304 B
Text

def euler_solution(df; x1; y1; x2; h):
def recursion(exp): reduce recurse(exp) as $x (.; $x);
h as $h
| [x1, y1]
| recursion( if ((.[0] < x2 and x1 < x2) or
(.[0] > x2 and x1 > x2)) then
[ (.[0] + $h), (.[1] + $h*df) ]
else empty
end )
| .[1] ;