Little explorations with HP calculators (no Prime)
|
04-19-2017, 06:40 PM
Post: #194
|
|||
|
|||
RE: Little explorations with the HP calculators
(04-19-2017 03:56 PM)pier4r Wrote: I was meaning something like "apply a RPL program to a list" (even if a function is a program as well). For what I know there is STREAM, DOSUBS (NSUB, ENDSUB), DOLIST. The Advanced Users Reference gives some insight into how those commands interpret the stack contents prior to execution. I don't think the program/function is parsed for evaluation, other than checking to see if it is only one command (thereby allowing the "n" argument to be skipped). The results of the function passed as an argument are checked, though. Consider these DOSUBS examples: Code: { 1 2 3 4 5 6 7 } « + » DOSUBS The output is a list of each subgroup of 2 items added together: { 3 5 7 9 11 13 } That one seems very sensible, and probably exactly what you would expect. Let's change it a little: Code: { 1 2 3 4 5 6 7 } 2 « + 0 DROP » DOSUBS Now for a twist. Let's keep the same input, but change the program to something entirely different (and totally unrelated to the actual input): Code: { 1 2 3 4 5 6 7 } 2 « DROP2 x y z » DOSUBS { x y z x y z x y z x y z x y z x y z } (6 sets of "x y z"). So you begin to see that DOSUBS really doesn't care much about the results of the function, and will simply group those results together in a result list based on the count of items in the source list taken 'n' at a time. If you really want to confuse yourself , ponder the following question: How does DOSUBS know how many stack items were returned by the program/function it was given as an argument? I would suggest you try some experiments with DOSUBS (similar to the above) to formulate an answer. These commands are complex creatures that perform a large number of behind-the-scenes operations. That's probably why they aren't known for their performance. I also find that I can't seem to remember exactly how they work (and all their quirks) without spending significant time with experiments and reading the manuals, which is probably why I rarely end up using them. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 15 Guest(s)