Trabb Pardo–Knuth algorithm
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
From the wikipedia entry: <lang pseudocode>
ask for 11 numbers to be read into a sequence S reverse sequence S for each item in sequence S call a function to do an operation if result overflows alert user else print result
</lang>
The task is to implement the algorithm:
- Use the function
- The overflow condition is an answer of greater than 400.
- The 'user alert' should not not stop processing of other items of the sequence.
- Print a prompt before accepting textual numeric input.
- You may optionally print the item as well as its associated result, but the results must be in reverse order of input.
- Show output from a typical run here.
- The sequence S may be 'implied' and so not shown explicitly.
Python
Functional
<lang python>Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> def f(x): return abs(x) ** 0.5 + 5 * x**3
>>> print(', '.join('%s:%s' % (x, v if v<=400 else "TOO LARGE!") for x,v in ((y, f(float(y))) for y in input('\nnumbers: ').strip().split()[::-1])))
numbers: 1 2 3 4 5 6 7 8 9 10 11 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.73205080756887, 2:41.41421356237309, 1:6.0 >>> </lang>