HP Forums
DOLIST/DOSUBS Equivalent? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: DOLIST/DOSUBS Equivalent? (/thread-4312.html)

DOLIST/DOSUBS Equivalent? - Helge Gabert - 07-06-2015 05:28 PM

The 50G has useful list-processing commands like DOSUBS and DOLIST.

It doesn't appear these (or something similar) exist in the Prime (see Chapter 25 of the Prime manual). Of course, some tasks (like computing moving averages for n elements of a list) can be achieved with seq (although that is a CAS command, but can be used in Home programs with CAS("seq( . . . )). And the users can always program their own specific application of list processing. But the beauty about DOLIST, for example, was that it could take operators and/or programs as arguments and was universal.

RE: DOLIST/DOSUBS Equivalent? - Tim Wessman - 07-06-2015 06:29 PM

Take a look at EXECON. It is actually more capable...

RE: DOLIST/DOSUBS Equivalent? - Helge Gabert - 07-06-2015 11:47 PM

Thanks! Will do - - for some reason, EXECON escaped me (it is listed under "other" in chapter 28 of the user's guide) - - I should have looked there as well.

RE: DOLIST/DOSUBS Equivalent? - Helge Gabert - 07-07-2015 12:38 AM

The second example for the EXECON help returns an error. What is going on there?

EXECON("&2-&1",{1,4,3,5}) -> Error. Syntax error.

I found that if one manually erases the "-" and replaces it with "-" it runs. Strange.

Otherwise, no problems.

RE: DOLIST/DOSUBS Equivalent? - Tim Wessman - 07-07-2015 01:55 PM

First guess without looking at it I'd say someone replaced the minus with a negative... I'll mark it down for review. Thanks!

RE: DOLIST/DOSUBS Equivalent? - Arno K - 07-07-2015 06:12 PM

Someone wanted a Simpson/Trapezoid numerical integral in another thread which should easily be doable using lists and their operations provided. My first attempt to get a locally defined function operating on a list simply was g(l), with the list stored in l, the function in g. This worked with the message I should use ".^" instead of ^ because of some matrix-operations awaited by the CAS, I chose "ok" and it provided the correct result, but the message is annoying so I opted for EXECON("g(&1)",l) which worked without any error.
But then I tried another function and still got the same result which finally brought me to the result: EXECON does not work with locally declared functions, at least in a cas-program, it uses the global one instead, is that a feature or a bug?

RE: DOLIST/DOSUBS Equivalent? - cyrille de brébisson - 07-08-2015 04:58 AM


It is an unfortunate side effect...

CAS/Numerical jumps do not carry on local context, so, when using EXECON in CAS, you do loose the local vars/programs.


RE: DOLIST/DOSUBS Equivalent? - Arno K - 07-08-2015 07:34 AM

Thank you, Cyrille,
I had read that, but totally forgot about it.