Talk:Trabb Pardo–Knuth algorithm
|WikiProject Computer science||(Rated Start-class, Mid-importance)|
What amazes me is that not only the algorithm itself is sensitive to math domain errors, but that none of the implementations I've seen given seem to do anything about it. (For very large positive values one could solve f(t)==400, yielding for t around 4.3, and write 'TOO LARGE' before ever evaluating f(t).) bsod 18:44, 1 June 2006 (UTC)
The algorithm states that the sequence S have to be reversed (not only visited in reverse order). In this sense, only python and ruby implementations are correct. This applies also to other implementations on the reference page. —Preceding unsigned comment added by 22.214.171.124 (talk) 16:02, 28 May 2008 (UTC)
It's kind of unclear why 400 is used as a stopping condition--it looks like a hack, and, if it's not, it should probably be explained. —Preceding unsigned comment added by 126.96.36.199 (talk) 17:20, 6 May 2011 (UTC)
Errors in examples
The algorithm states you MUST supply a user defined function for the main loop of the function to call. What the algorithm wants people to do is to provide a brief snippet of code that shows how one does the things in the algorithm using a particular language. Myself, I'ld say the algorithm's developers intended that an exception be thrown when the result is out of bounds, and in the main loop the exception is caught (where this capability exists in the language).
I modified the Python and Ruby examples accordingly. I don't know Perl (and if I did, wouldn't admit to it). From all the examples on the web, it seems like Perl mongers don't use functions, preferring instead write everything as an inline script. Unable to modify the example, I removed it. --188.8.131.52 (talk) 02:14, 31 January 2008 (UTC)
Isn't it the case that the three programs print different results? They all print the calculated values based on the input, but the ALGOL prints the ordinals of the input (1..11), the ruby prints the values, and the Ocaml prints neither. Marcameyer (talk) 15:47, 1 February 2009 (UTC)
The page says:
list instead of an array, (although there is an array module available) The writer seems to assume the python list type is not an array. It's a resizable vector type (implemented as an array). The python array module is for storing masses of ints or floats without Object overhead.
for i in [int(raw_input()) for i in range(11)][::-1]
ALGOL source code
I reformatted the ALGOL code to make it more readable. In particular, it wasn't obvious where the f() procedure ends and the statements in the outer begin/end block begin. I'm not an Algol expert, so if I got any of it wrong, please feel free to correct it. — Loadmaster 17:51, 15 May 2007 (UTC)
Original Implementations for Direction
Would is be possible to post the original implementations by Trabb et al verbatim? Doing so would help clarify the intent of the authors. Is it to compare the syntax of various languages for demonstrational purposes? To achieve the goal in as little code as possible, golf-style? The original implementations might set better direction from the originators. Maerics 04:44, 27 June 2007 (UTC)
Needs fewer implementations
The current article has implementations in pseudocode, ALGOL 60, Perl, Python, and Ruby, and I just removed one in Smalltalk. We should have at most three implementations here, and perhaps fewer. (See this old WPPL talk thread.) It looks to me like the Python and Ruby examples are basically equivalent, but I'm not fluent in either language, so it's hard to tell whether the Ruby one might be showing something interesting about blocks.
Ideally, we would have the algorithm in pseudocode, plus the original implementation in ALGOL 60 (not reformatted or changed in any way), maybe plus one or two in modern languages if they illustrate useful features that are common in modern languages but aren't already present in the ALGOL 60 example.
Any takers for a restructuring of the example implementations? (If you change the current languages, remember to use the Articles with example code categories appropriately, and don't make up new subcategories.) --Quuxplusone 21:06, 21 October 2007 (UTC)