Post Reply 
No way to get an element free of brackets
02-14-2021, 03:45 PM (This post was last modified: 02-15-2021 08:01 AM by essen.)
Post: #4
RE: No way to get an element free of brackets
(02-13-2021 05:38 PM)Albert Chan Wrote:  
(02-13-2021 09:58 AM)essen Wrote:  lst2(i1):=lst1(i1);

I am not sure the question is, but above can be confused with function definition.

Perhaps you meant lst2[i1] := lst1[i1] ?

Or, if you really wanted to assign global variables to values (why ?)

CAS> lst1 := {1, 2, 3}
CAS> lst2 := {"myv1", "myv2", "myv3"}
CAS> FOR i1 FROM 1 TO 3 DO expr(lst2[i1] + ":=" + lst1[i1]); END;

CAS> myv1, myv2, myv3       → [1, 2, 3]
-----------------------------------------------

Your method now works.
I up-grated in the evening to ver. 2.1.14425 (2020 01 16)
It rather likely I had a programming error that has been corrected
along the way without knowing this possibly could be responsible, but
not the Prime version. Don't know for sure.

//LSTOR({−59.0955172399,−25.2673105008,−31.5033804435,39.3,−4.5,9.5},{"ɷ2","ɷ1","y2","x2","y0","x0"})
#cas
n:=0;
LSTOR(l1,l2):=
BEGIN
LOCAL i1:=1,si;
ls1:=l1;
ls2:=l2;
si:=length(ls2);
FOR i1 FROM 1 TO si DO
expr(""+ls2[i1]+":="+ls1[i1]);
END;
IF (i1==si+1) THEN n:=1;
END;
END;
#end

This cryptic way to strip the brackets in lack of a dedicated
stripping command gets me saying; We still needs a dedicated
stripping command to do this. The problem exist with a Vector list too. And still, none of these works:
get({1,2,3},2) or sub({1,2,3},1,2). Neither in Home using GET and SUB. The subtracted element using the sub in cas or SUB in HOME are just placed enclosed in list brackets. The get or GET does nothing.

I would like seeing a method for this.
But, Thank you for your method.

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-14-2021 03:45 PM



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