RosettaCodeData/Task/Trabb-Pardo-Knuth-algorithm/00-TASK.txt

26 lines
1.5 KiB
Plaintext
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.

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 [http://bitsavers.org/pdf/stanford/cs_techReports/STAN-CS-76-562_EarlyDevelPgmgLang_Aug76.pdf 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 [[wp:Trabb PardoKnuth algorithm|wikipedia entry]]:
'''ask''' for 11 numbers to be read into a sequence ''S''
'''reverse''' sequence ''S''
'''for each''' ''item'' '''in''' sequence ''S''
''result'' ''':=''' '''call''' a function to do an ''operation''
'''if''' ''result'' overflows
'''alert''' user
'''else'''
'''print''' ''result''
The task is to implement the algorithm:
# Use the function: &nbsp; &nbsp; <big><math>f(x) = |x|^{0.5} + 5x^3</math></big>
# The overflow condition is an answer of greater than 400.
# The 'user alert' should not stop processing of other items of the sequence.
# Print a prompt before accepting '''eleven''', textual, numeric inputs.
# You may optionally print the item as well as its associated result, but the results must be in reverse order of input.
# The sequence &nbsp; ''' ''S'' ''' &nbsp; may be 'implied' and so not shown explicitly.
# ''Print and show the program in action from a typical run here''. (If the output is graphical rather than text then either add a screendump or describe textually what is displayed).
<br><br>