Understanding DOLIST
|
10-05-2016, 06:22 PM
Post: #1
|
|||
|
|||
Understanding DOLIST
I was trying to understand DOLIST command with an example I found in the web:
{1 2 3} {4 5 6} {7 8 9} 3 <<+ *>> 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: (7+4)*1=11 (8+5)*2+=26 (9+6)*3=45 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? Thanks Luis |
|||
10-05-2016, 08:56 PM
(This post was last modified: 10-05-2016 08:59 PM by wojtek.)
Post: #2
|
|||
|
|||
RE: Understanding DOLIST
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. |
|||
10-05-2016, 11:09 PM
Post: #3
|
|||
|
|||
RE: Understanding DOLIST
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.
|
|||
10-06-2016, 06:54 AM
Post: #4
|
|||
|
|||
RE: Understanding DOLIST
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 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
10-06-2016, 01:50 PM
Post: #5
|
|||
|
|||
RE: Understanding DOLIST
Thanks for all you replies.
Werner, you've got it right. Luis |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)