loops
#1

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.

#2

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)

#3

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.

#4

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)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Loops in Prime Geoff Quickfall 4 1,536 10-02-2013, 10:45 AM
Last Post: Geoff Quickfall
  39gii Tutorial: FOR loops is posted Eddie W. Shore 0 949 03-16-2013, 12:13 PM
Last Post: Eddie W. Shore
  Using loops and SOLVE together Matt Agajanian 5 1,622 03-25-2012, 09:02 PM
Last Post: bill platt
  Loops of Addition benchmark for the 41CL Monte Dalrymple 8 1,975 08-19-2010, 09:48 PM
Last Post: Wlodek Mier-Jedrzejowicz
  Loops of addition Palmer O. Hanson, Jr. 7 1,818 06-21-2010, 05:26 AM
Last Post: Don Shepherd
  Loops on 48GX V Green 3 1,132 04-25-2005, 05:53 AM
Last Post: Raymond Del Tondo
  17BII and 19BII indefinite loops ? Vincent Weber 0 631 09-10-2004, 03:52 AM
Last Post: Vincent Weber

Forum Jump: