Post Reply 
No way to get an element free of brackets
02-17-2021, 05:52 PM
Post: #7
RE: No way to get an element free of brackets
(02-17-2021 10:48 AM)Didier Lachieze Wrote:  Here is a simplified way to use lists to assign values to global variables, not requiring CAS:

Code:
EXPORT myv1, myv2, myv3;

EXPORT LSTOR(l1,l2)
BEGIN
 EXPR(l2+":="+l1);
END;

EXPORT TST()
BEGIN
 LOCAL lstv;
 lstv:={"myv1", "myv2", "myv3"};
 LSTOR({1,2,3},lstv);
 PRINT(myv1+" "+myv2+" "+myv3);
 LSTOR({4,5,6},lstv);
 PRINT(myv1+" "+myv2+" "+myv3);
END;

------------------------

I tried it out.

It works only when these variables has been defined ahead in user memory.
You did define them ahead with the EXPORT before running. Yours also
works having this expression, EXPR({"myv1","myv2"}+":="+{1,2}),
in the Primes input window, when the variables has been defined ahead.
Otherwise, not defined ahead it errors.
With the calculator in cas mode and same, or as, expr({"myv1","myv2"}+":="+{1,2}), it won't work, even with variables defined ahead.

With the code I posted running this, LSTOR({1,2},{"myv1","myv2"}),
it works without having the variables defined ahead. That was my gold.

But your method can be used instead of this FOR LOOP in my cas
LSTOR program. This makes it a bit easier.

Some inconsistency are observed.

Thank you

essen
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: No way to get an element free of brackets - essen - 02-17-2021 05:52 PM



User(s) browsing this thread: 1 Guest(s)