How to resolve the algorithm Trabb Pardo–Knuth algorithm step by step in the ERRE programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Trabb Pardo–Knuth algorithm step by step in the ERRE programming language
Table of Contents
Problem Statement
The TPK algorithm is an early example of a programming chrestomathy. It was used in Donald Knuth and Luis Trabb Pardo's Stanford tech report The Early Development of Programming Languages. The report traces the early history of work in developing computer languages in the 1940s and 1950s, giving several translations of the algorithm. From the wikipedia entry: The task is to implement the algorithm:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Trabb Pardo–Knuth algorithm step by step in the ERRE programming language
Source code in the erre programming language
!Trabb Pardo-Knuth algorithm
PROGRAM TPK
!VAR I%,Y
DIM A[10]
FUNCTION F(T)
F=SQR(ABS(T))+5*T^3
END FUNCTION
BEGIN
DATA(10,-1,1,2,3,4,4.3,4.305,4.303,4.302,4.301)
FOR I%=0 TO 10 DO
READ(A[I%])
END FOR
FOR I%=10 TO 0 STEP -1 DO
Y=F(A[I%])
PRINT("F(";A[I%];")=";)
IF Y>400 THEN PRINT("--->too large<---")
ELSE PRINT(Y)
END IF
END FOR
END PROGRAM
You may also check:How to resolve the algorithm Currying step by step in the Quackery programming language
You may also check:How to resolve the algorithm Pentagram step by step in the ooRexx programming language
You may also check:How to resolve the algorithm Determine sentence type step by step in the Lua programming language
You may also check:How to resolve the algorithm Look-and-say sequence step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Binary digits step by step in the Groovy programming language