Trabb Pardo–Knuth algorithm: Difference between revisions

Added AutoHotkey
(Added AutoHotkey)
Line 445:
f(2) = 41.4142135623731
f(1) = 6</pre>
 
=={{header|AutoHotkey}}==
<lang AutoHotkey>seq := [1,2,3,4,5,6,7,8,9,10,11]
MsgBox % result := TPK(seq, 400)
return
 
TPK(s, num){
for i, v in reverse(s)
res .= v . " : " . ((x:=f(v)) > num ? "OVERFLOW" : x ) . "`n"
return res
}
reverse(s){
Loop % s.Count()
s.InsertAt(A_Index, s.pop())
return s
}
f(x){
return Sqrt(x) + 5* (x**3)
}</lang>
{{out}}
<pre>11 : OVERFLOW
10 : OVERFLOW
9 : OVERFLOW
8 : OVERFLOW
7 : OVERFLOW
6 : OVERFLOW
5 : OVERFLOW
4 : 322.000000
3 : 136.732051
2 : 41.414214
1 : 6.000000</pre>
 
=={{header|AWK}}==
299

edits