# Rapid variable assignment with lists? Is this possible? - Hewlett Packard

This is a discussion on Rapid variable assignment with lists? Is this possible? - Hewlett Packard ; Hi everyone, I have saved a somewhat time consuming but trivial integral into a variable 'H'. This integral takes two temperatures (T1,T2) and 4 heat capacity variables (A,B,C,D). Is there any way I could set this up so I could ...

# Thread: Rapid variable assignment with lists? Is this possible?

1. ## Rapid variable assignment with lists? Is this possible?

Hi everyone,

I have saved a somewhat time consuming but trivial integral into a
variable 'H'. This integral takes two temperatures (T1,T2) and 4 heat
capacity variables (A,B,C,D). Is there any way I could set this up so
I could just pass a list containing values for these variables (T1 T2
A B C D) to the calculator and have it automatically Assign all the
variables?

If not, would it be simple enough to turn this into a function that
takes these variables? If it is really easy, could you post some
sample code that would get me on my way?

Thanks a bunch!

2. ## Re: Rapid variable assignment with lists? Is this possible?

On Jun 25, 8:08*pm, Kyle Andrews wrote:
> Hi everyone,
>
> I have saved a somewhat time consuming but trivial integral into a
> variable 'H'. This integral takes two temperatures (T1,T2) and 4 heat
> capacity variables (A,B,C,D). Is there any way I could set this up so
> I could just pass a list containing values for these variables (T1 T2
> A B C D) to the calculator and have it automatically Assign all the
> variables?
>
> If not, would it be simple enough to turn this into a function that
> takes these variables? If it is really easy, could you post some
> sample code that would get me on my way?
>
> Thanks a bunch!

{t1 t2 a b c d} {T1 T2 A B C D} STO

3. ## Re: Rapid variable assignment with lists? Is this possible?

On Jun 25, 8:08*pm, Kyle Andrews wrote:
> Hi everyone,
>
> I have saved a somewhat time consuming but trivial integral into a
> variable 'H'. This integral takes two temperatures (T1,T2) and 4 heat
> capacity variables (A,B,C,D). Is there any way I could set this up so
> I could just pass a list containing values for these variables (T1 T2
> A B C D) to the calculator and have it automatically Assign all the
> variables?
>
> If not, would it be simple enough to turn this into a function that
> takes these variables? If it is really easy, could you post some
> sample code that would get me on my way?
>
> Thanks a bunch!

Kyle,

I like using a local variable structure when a lot of variables are
involved.
Put your variables in a list on stack level 1 and then decompose the
list and store the values into local variables.
1: {1 2 3 4 5 6}
<< LIST-> @decompose list
DROP @remove number of objects in list
-> t1 t2 a b c d @store values in local variables
<< @your program goes here>>
>>

Mark

4. ## Re: Rapid variable assignment with lists? Is this possible?

On Jun 25, 11:07*pm, mnhollin...@yahoo.com wrote:
> On Jun 25, 8:08*pm, Kyle Andrews wrote:
>
> > Hi everyone,

>
> > I have saved a somewhat time consuming but trivial integral into a
> > variable 'H'. This integral takes two temperatures (T1,T2) and 4 heat
> > capacity variables (A,B,C,D). Is there any way I could set this up so
> > I could just pass a list containing values for these variables (T1 T2
> > A B C D) to the calculator and have it automatically Assign all the
> > variables?

>
> > If not, would it be simple enough to turn this into a function that
> > takes these variables? If it is really easy, could you post some
> > sample code that would get me on my way?

>
> > Thanks a bunch!

>
> Kyle,
>
> I like using a local variable structure when a lot of variables are
> involved.
> Put your variables in a list on stack level 1 and then decompose the
> list and store the values into local variables.
> 1: {1 2 3 4 5 6}
> << LIST-> @decompose list
> DROP @remove number of objects in list
> -> t1 t2 a b c d @store values in local variables
> << @your program goes here>>
>
>
>
> Mark

Don't forget the closing right delimeters. I put them in this web form
but they didn't
appear. I see some of the other guys use /<< instead of << when
posting. Maybe
<< means something in HTML(?) and it cuts them from the end of the
post. By
convention, the local variable names use lower case letters.

5. ## Re: Rapid variable assignment with lists? Is this possible?

In article
<442a3f92-eb47-4bdb-a62f-5a5baa5f3074@8g2000hse.googlegroups.com>,
mnhollinger@yahoo.com wrote:

> On Jun 25, 8:08*pm, Kyle Andrews wrote:
> > Hi everyone,
> >
> > I have saved a somewhat time consuming but trivial integral into a
> > variable 'H'. This integral takes two temperatures (T1,T2) and 4 heat
> > capacity variables (A,B,C,D). Is there any way I could set this up so
> > I could just pass a list containing values for these variables (T1 T2
> > A B C D) to the calculator and have it automatically Assign all the
> > variables?
> >
> > If not, would it be simple enough to turn this into a function that
> > takes these variables? If it is really easy, could you post some
> > sample code that would get me on my way?
> >
> > Thanks a bunch!

>
> Kyle,
>
> I like using a local variable structure when a lot of variables are
> involved.
> Put your variables in a list on stack level 1 and then decompose the
> list and store the values into local variables.
> 1: {1 2 3 4 5 6}
> << LIST-> @decompose list
> DROP @remove number of objects in list
> -> t1 t2 a b c d @store values in local variables
> << @your program goes here>>

Quicker than LIST-> DROP , is EVAL.
When EVAL is used on a list, it merely strips off the list delimiters
and puts the listed objects on the stack, which is what LIST-> DROP
does..

6. ## Re: Rapid variable assignment with lists? Is this possible?

On Jun 26, 3:53*am, Virgil wrote:
> In article
> <442a3f92-eb47-4bdb-a62f-5a5baa5f3...@8g2000hse.googlegroups.com>,
>
>
>
>
>
> *mnhollin...@yahoo.com wrote:
> > On Jun 25, 8:08*pm, Kyle Andrews wrote:
> > > Hi everyone,

>
> > > I have saved a somewhat time consuming but trivial integral into a
> > > variable 'H'. This integral takes two temperatures (T1,T2) and 4 heat
> > > capacity variables (A,B,C,D). Is there any way I could set this up so
> > > I could just pass a list containing values for these variables (T1 T2
> > > A B C D) to the calculator and have it automatically Assign all the
> > > variables?

>
> > > If not, would it be simple enough to turn this into a function that
> > > takes these variables? If it is really easy, could you post some
> > > sample code that would get me on my way?

>
> > > Thanks a bunch!

>
> > Kyle,

>
> > I like using a local variable structure when a lot of variables are
> > involved.
> > Put your variables in a list on stack level 1 and then decompose the
> > list and store the values into local variables.
> > 1: {1 2 3 4 5 6}
> > << LIST-> @decompose list
> > DROP @remove number of objects in list
> > -> t1 t2 a b c d @store values in local variables
> > << @your program goes here>>

>
> Quicker than LIST-> DROP , is EVAL.
> When EVAL is used on a list, it merely strips off the list delimiters
> and puts the listed objects on the stack, which is what LIST-> DROP
> does..- Hide quoted text -
>
> - Show quoted text -

Thanks Virgil, I never knew that. I just dusted off my HP 48G
series AUR manual and on page 3-107 under "Obj. Type" is
"List" and under "Effect of Evaluation" item 4 reads
"Other objects are put on the stack."

7. ## Re: Rapid variable assignment with lists? Is this possible?

On Jun 26, 10:22 pm, mnhollin...@yahoo.com wrote:
> On Jun 26, 3:53 am, Virgil wrote:
> > Quicker than LIST-> DROP , is EVAL.
> > When EVAL is used on a list, it merely strips off the list delimiters
> > and puts the listed objects on the stack, which is what LIST-> DROP
> > does..

>
> Thanks Virgil, I never knew that. I just dusted off my HP 48G
> series AUR manual and on page 3-107 under "Obj. Type" is
> "List" and under "Effect of Evaluation" item 4 reads
> "Other objects are put on the stack."

EVAL is equivalent to LIST-> DROP for a list of values, but they give
different results when functions are used in the list. For example:

{ 1 2 3 SQ } LIST-> DROP
results in
4: 1
3: 2
2: 3
1: SQ

while { 1 2 3 SQ } EVAL
results in
4:
3: 1
2: 2
1: 9

-wes

8. ## Re: Rapid variable assignment with lists? Is this possible?

Thanks for the help!

9. ## Re: Rapid variable assignment with lists? Is this possible?

{ 1 2 3 } { A B C } stores 1 into 'A', 2 into 'B', 3 into 'C'

{ stuff } EVAL executes stuff just as in a program,
but note that any quoted 'name' or \<< program \>>
remains unquoted within a list,
so that either is immediately evaluated,
instead of being simply put on the stack.

[r->] [OFF]