HP Forums

Full Version: Understanding DOLIST
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was trying to understand DOLIST command with an example I found in the web:

{1 2 3}
{4 5 6}
{7 8 9}
<<+ *>>

Number 3 is the number of lists, as explained in the example.

The answer is {11 26 45}

I understand the calculator is doing this:

But if I change 3 and put 2, the answer is:
{2145 4290 6435}

Can you explain what is the procedure the calculator is doing?


Interesting. Probably a bug or "undocumented feature" :-)
You gave not the calculator name nor rom ver, I checked it on 50g ver 1.15 and got the same results.
The explanation is simple, two operators in << + * >> need 3 arguments. If you change 3 for 2 the calculator takes the 3rd list from the stack (it should not do it!) and gives some values instead of "argument missing" error message. What it is doing? perhaps only developers know.
If you change 3 for 2 and remove the 3rd list, or change 3 for 4 or 1 or other value the calculator gives an error message as it should.
Hello LVGE, I'll ask you to modify your program like this « HALT + * » ( in this way your program stops every time DOLIST calls it), then go to [LeftShift] [EVAL] [LeftShift .] [NEXT] [F3], every time the program halts use [F2] and observe the process. A hint: with 2 you specify DOLIST to work with just two lists but your program needs three arguments.
With the third list in place, it will multiply that list by the respective sums of elements from the lists in level 1 and 2, just like expected. No bug here.
{ 1 2 3 } * (4+7) * (5+8) * (6+9) = {2145 4290 6435}

Cheers, Werner
Thanks for all you replies.
Werner, you've got it right.

Reference URL's