The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

loops
Message #1 Posted by VGreen on 10 Feb 2005, 9:32 a.m.

Here's the problem:

HP 48GX

(A) I have six values: 1,2,8,6,4, and 9, and I want to subtract 2 from 1, 8 from 2, 6 from 8 etc., and I want to assign (1) to my first answer and (2) to my second answer, i.e., 1=-1; 2=-6; 3=2; etc. I want to be able to enter the six values one after the other and then obtain the result.

(B) I would also like to store all the negative results in one column and all the positives in another and access them later. I would also like to store the sum of the negatives and the sum of the positives in separate columns and access them later.

(C) Finally, I would like to take value 1 and add it to result 1 and store it; value 2 and add it to result 2 and store it in the same column as the previous one, etc., so I can bring up a column of all the results later.

Any assistance would be greatly appreciated.

      
Re: loops
Message #2 Posted by Vieira, Luiz C. (Brazil) on 10 Feb 2005, 10:52 p.m.,
in response to message #1 by VGreen

Hi, VGreen;

two very interesting functions available with the HP48 that might help you a lot are DOLIST (item 3) and DOSUBS (items 1 and 2). If you have the HP48G Advanced Users Reference Manual, see pages 3-91 to 3-93. The related command STREAM may also help.

If you need advice about these commands or any additional help building your program, please post again.

Chhers.

Luiz (Brazil)

            
Re: loops
Message #3 Posted by VGreen on 11 Feb 2005, 11:52 p.m.,
in response to message #2 by Vieira, Luiz C. (Brazil)

Thanks Luiz. I'll try to obtain a copy of the advanced manual and see what I can come up with. But I may later take you up on your offer for more help, as I'm very green at this presently.

Take care.

                  
Re: loops
Message #4 Posted by Vieira, Luiz C. (Brazil) on 12 Feb 2005, 3:21 a.m.,
in response to message #3 by VGreen

Hi, VGreen;

just to give you a small sample of what can be done (I read your post again ant took some minutes wondering about but I did not get to a final solution so far, O.K.?)

1 - take a list with your numbers in stack level 1: (consider you have already entered them)

{ 1 2 8 6 4 9 }
2 - add a program to the stack with a single 'subtraction': (previous list is pushed to level 2)
 - 
3 - execute DOSUBS and you'll have:
{ -1 -6 2 2 5 )
In this single form, DOSUBS applies the operation defined in level one (the program) to each pair of elements in the list in level 2, left to right. If you dplicate the list prior to execute DOSUBS, you'll keep a copy of it to perform the other operations.

I'll work on it and let you know what I get. Three questions:

1 - is there any particular way you want to enter the six numbers? There are many ways, by using PROMPT, INPUT and even custom routines;
2 - the output with a sequenced reference: do you need just a visual reference or you actually need to store the resulting values with a sequenced index? Each object in a list has already an index. Fos instance, if you store

{ 1 2 8 6 4 9 }
with the number 'LST01', then 'LST01(1)' EVAL returns 1, 'LST01(3)' EVAL returns 8, etc.
3 - the columns with positive and negative numbers: do you want a separate object for each or it can be a [n 2] matrix with all elements on it? If so, [SIGMA+] with statistic functions are the best set of tools in this case.

Cheers.

Luiz (Brazil)


[ Return to Index | Top of Index ]

Go back to the main exhibit hall