Trabb Pardo–Knuth algorithm: Difference between revisions
Content added Content deleted
(→Procedural: read single number per line; update to more modern Python (string interpolation, walrus operator)) |
|||
Line 2,704: | Line 2,704: | ||
f(0.470145):1.20527 |
f(0.470145):1.20527 |
||
</pre> |
</pre> |
||
=={{header|Picat}}== |
|||
<lang Picat>import util. |
|||
go => |
|||
L = [I.parse_term() : I in split(read_line())], |
|||
S = [[I,cond(F<=400,F,'TOO LARGE')] : I in L.len..-1..1, F=f(L[I])], |
|||
println(S), |
|||
nl. |
|||
f(T) = sqrt(abs(T)) + 5*T**3.</lang> |
|||
Example run: |
|||
{{out}} |
|||
<pre> |
|||
$ echo "1 2 3 4 5 6 7 8 9 10 11" | picat tpk.pi |
|||
[[11,TOO LARGE],[10,TOO LARGE],[9,TOO LARGE],[8,TOO LARGE],[7,TOO LARGE],[6,TOO LARGE],[5,TOO LARGE],[4,322.0],[3,136.732050807568868],[2,41.414213562373092],[1,6.0]]</pre> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |