RosettaCodeData/Task/Trabb-Pardo-Knuth-algorithm/M2000-Interpreter/trabb-pardo-knuth-algorithm-2.m2000
2023-07-01 13:44:08 -04:00

24 lines
750 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Global a$
Document a$ ' make a$ as a document - string with paragraphs
Module Run {
a$<={Trabb PardoKnuth algorithm
f(x)=Sqrt(Abs(x))+5*x^3
}
if not match("NNNNNNNNN") then Error "Need 11 numbers"
Shiftback 1, -11 ' reverse order 11 elements of stack of values
Def f(x)=Sqrt(Abs(x))+5*x^3
For i=1 to 11 {
Read pop
y=f(pop)
if y>400 Then {
a$<=format$("f({0}) = Overflow!", pop)+{
}
} Else {
a$<=format$("f({0}) = {1}", pop, y)+{
}
}
}
}
Run 10, -1, 1, 2, 3, 4, 4.3, 4.305, 4.303, 4.302, 4.301
Run 1, 2, 3, -4.55,5.1111, 6, -7, 8, 9, 10, 11
Clipboard a$