cancel
Showing results for
Did you mean:
Level 1
12 7 0 1
Message 1 of 3
550
Flag Post

HP Prime Create List That Includes an Expression

HP Recommended
HP Prime

I have been attempting to create a list that includes an expression that I would like to iterate between a lower and upper limit. I’ve tried numerous approaches, all unsuccessful. Here’s what I am trying to accomplish.

Expression = w*(L/2-(x))

Variables w, L and RL have been previously defined in program. I would like to iterate the expression from x=L/10 to L in steps of L/10 and include all iterated values in a list. I also want to include in the list static values at specified locations in the list.

The desired list would look like this:

{0, 15, RL, w*(L/2-(0.1*L), w*(L/2-(0.2*L), w*(L/2-(03*L), w*(L/2-(0.4*L), w*(L/2-(0.5*L), w*(L/2-(0.6*L), w*(L/2-(0.7*L), w*(L/2-(0.8*L), w*(L/2-(0.9*L), w*(L/2-(L), 0}

Any assistance or suggestions would be much appreciated.

Tags (3)
2 REPLIES 2
Level 8
747 744 121 187
Message 2 of 3
Flag Post
HP Recommended

Hello,

The key is to use quoted expressions to avoid evaluation. QUOTE( ) or else just ' ' around it. Once you have a quoted expression, you can easily then build up the expression as the quote avoid evaluation.

For example: 'A' + 1 / 2  in the homescreen will result in 'A+1/2' being left there.

Here's a bit of code to get you started

EXPORT test()
BEGIN
LOCAL mylist:={ 0, 15, 'RL' }; //see how I quote the RL to avoid evaluation at this time
FOR J FROM 0 TO 10 DO
mylist:=CONCAT(mylist,'W'+J);
END;
END

Now if you are just wanting the final value, you can do that with not quoting your argument when CONCAT is called.

You could also just call EVAL(mylist) at the very end to get your full evaluation at that time if that works better.

TW

Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.
Level 1
12 7 0 1
Message 3 of 3
Flag Post
HP Recommended

Thanks, Tim. Did the trick. Much appreciated.

† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation