Symbolic reference question
|
06-08-2020, 09:40 PM
Post: #1
|
|||
|
|||
Symbolic reference question
Within a program I have arrived at:
c:={a,b} d:={100.5,102.5} At the command entry line, I can enter {a,b}:={100.5,102.5}, after which: a:=100.5 b:=102.5 What I would like to do is make the {a,b} = {100.5,102.5} assignment by using the variables c and d, instead. How can this be accomplished? Something like: c:=d, or EXECON("&1:=&2",c,d), I'm having trouble accessing the contents of the variables appropriately. Thanks! -Dale- |
|||
06-09-2020, 06:27 AM
Post: #2
|
|||
|
|||
RE: Symbolic reference question
Hello,
Sorry, appart from using execon, there is no other solution at the moment. note that you should have c:={'a','b'} so that c contains {a,b}... Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
06-09-2020, 08:41 AM
Post: #3
|
|||
|
|||
RE: Symbolic reference question
In CAS you can also use: zip('sto',d,c)
|
|||
06-09-2020, 09:32 AM
Post: #4
|
|||
|
|||
RE: Symbolic reference question
Thank you, Cyrille.
Within the program I had used c:={'a','b'}, and that was how I was able to get to the point where c={a,b}. However, I haven't been successful with: EXECON("&1:=&2",c,d); Can you think of a syntax that works? I've tried several ways, with no success. This seems like such a basic operation. It's surprising that symbolic references, don't seem to be programmable, even though directly using the contents of the symbolic reference works. Summary: [CAS] purge({a,b}); c:={'a','b'}; d:={100.5,102.5}; c:=d; // ==> c gets set to the contents of d, (as expected). EXECON("&1:=&2",c,d); // Error message ... {a,b}:={100.5,102.5}; // a=100.5; b=102.5 (Works. How to get to this result, using the symbolic reference?) |
|||
06-09-2020, 10:17 AM
Post: #5
|
|||
|
|||
RE: Symbolic reference question | |||
06-09-2020, 12:31 PM
Post: #6
|
|||
|
|||
RE: Symbolic reference question | |||
06-09-2020, 01:29 PM
Post: #7
|
|||
|
|||
RE: Symbolic reference question
error is due to the := adding some form of " " may help;
i had similar problem; can not seem to remember the way a i used "" to solve this problem. try Step 1. EXECON("""&1:=&2""",c,d); Step 2. EXPR(Step 1) |
|||
06-10-2020, 05:49 AM
Post: #8
|
|||
|
|||
RE: Symbolic reference question
Hello,
execon does not work because execon adds () around each object to avoid user unexpected results... things like L1:={1+i, 2+i} execon("&*2", L1) would execute 1+i*2 and 2+i*2 (which is not what the user was expecting) if they were no guard () added... in your case, you end up with (a):=(1) which will not work... I am afraid that the solution here is an EXPR... you might be able to do some variation of EXPR(MAKELIST(L1(I)+":=",I,1,SIZE(L1))+L2) PPL is not a symbolic language, as such it is not designed to manipulate variables. variable content? yes, variables themselves as objects? not really.. is it impossible, obviously no, but it is not super easy either. Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
10-03-2020, 02:05 AM
Post: #9
|
|||
|
|||
RE: Symbolic reference question
I'd say the best solution would be to use a helper function:
Code:
the 'seq' function can also be used here Code:
if you need a more generalized solution: Code:
Having functions be first class is a really powerful feature of CAS, please use it. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)