Problems with eval(IdentifierName,#recall)
|
02-27-2017, 03:08 PM
(This post was last modified: 02-28-2017 01:13 PM by compsystems.)
Post: #1
|
|||
|
|||
Problems with eval(IdentifierName,#recall)
Hello, the following statements executed line by line in the history of CAS view, show the following output [8, 8, id2, id1, id0, 8, 8], but within a program [id1,id0,id2,id1,id1,id1,id1] Why?
Please follow the following steps orderly to see the problem 1: [Shift]+[mem] /userVars, [DELETE]id0, id1, id2 & CAS Vars id0, id1, id2 2: firts goto CAS & HISTORY VIEW 2.1: id0:=8; id1:='id0'; id2:='id1'; [ENTER] // store id2,id1,id0 in the CAS environment 2.2: [ id2, eval(id2), eval(id2,0), eval(id2,1), eval(id2,2), eval(id2,3), eval(id2,4) ]; [ENTER] // returns [8, 8, id2, id1, id0, 8, 8] 3: then goto HOME & HISTORY VIEW // recall IDs in the CAS environment 3.1: { id2, CAS.eval(id2), CAS.eval(id2,0), CAS.eval(id2,1), CAS.eval(id2,2), CAS.eval(id2,3), CAS.eval(id2,4) } [ENTER] // returns {id1,id0,id2,id1,id0,8,8} 4: NOW AS PRGM return or goto CAS mode 4.1: purge(id0, id1, id2); [ENTER] before running the program, to delete pre-assigned data, although it should not be so, since ID0, ID1, ID2 are local variables within of prgm, why is it calling EVAL to global variables? If id0 is local, should call local ID0 and not global ID0 id2,id1,id0; [ENTER] //returns id2,id1,id0 4.2: RCLidsCAS(); [ENTER] // returns [id1,id0,id2,id1,id1,id1,id1] ? id2,id1,id0; [ENTER] //returns id2,id1,id0 4.3: RCLidsHOME(); [ENTER] // returns [id1,id0,id2,id1,id1,id1,id1] ? 5: switch HOME VIEW id2,id1,id0; [ENTER] //returns id2,id1,id0 5.1: RCLidsHOME(); [ENTER] // returns [id1,id0,id2,id1,id1,id1,id1] ? id2,id1,id0; [ENTER] //returns id2,id1,id0 5.2: RCLidsCAS(); [ENTER] // the virtual calculator is locked and creates global variables, id0, id1, id2, why? PHP Code: #cas 6: goto HOME VIEW 6.1: purge(id0, id1, id2); [ENTER] 6.2: Now if you define variables in HOME VIEW id0:=8; id1:='id0'; id2:='id1';[ENTER] // store id2,id1,id0 in the HOME environment 7: goto CAS VIEW 7.1: RCLidsCAS(); [ENTER] returns [8, 8, id2, id1, id0, 8, 8] Why? EVAL command, must first call the local variables and then the global variables |
|||
02-27-2017, 08:15 PM
Post: #2
|
|||
|
|||
RE: Problems with eval(IdentifierName,#recall)
In CAS programs, evaluation is done at level 1 instead of 25 for interactive evaluation.
|
|||
02-28-2017, 12:32 PM
(This post was last modified: 02-28-2017 12:56 PM by compsystems.)
Post: #3
|
|||
|
|||
RE: Problems with eval(IdentifierName,#recall)
(02-27-2017 08:15 PM)parisse Wrote: In CAS programs, evaluation is done at level 1 instead of 25 for interactive evaluation.understood for CAS PRGM id0:=8; id1:='id0'; // OR id1:=quote(id0); id2:='id1'; id2; // 'id1' // ok, 1 LEVEL of evaluationand and not continuous ... -> 8 as HOME MODE eval(id2); // 'id0' // 2 LEVELS, Why? EVAL cmd should assess if not one level at all levels eval(id2,0); // id2 -> 'id2' // ok, I interpret it as not evaluating eval(id2,1); // id2 -> 'id1' // ok, 1 LEVEL BUT eval(id2,2); // id2 -> 'id1' // must be 2 levels of evaluation id2 -> 'id1' -> 'id0' , otherwise for what is the second argument? Now the logic of the program changes (to check the problem follow the previous steps 6 to 7.1), if there are stored variables in HOME VIEW and there is no way to delete those variables from a CAS prgm, so I request new commands PURGE() only for HOME environment & PURGEcas() only for CAS environment In step 5,this must also be solved, Why global variables are created |
|||
02-28-2017, 12:43 PM
(This post was last modified: 02-28-2017 12:45 PM by Han.)
Post: #4
|
|||
|
|||
RE: Problems with eval(IdentifierName,#recall)
You delete Home variables using: DelHVars("name") or DelHVars({ "list", "of", "names" });
The purge() command is a CAS command; it will only delete CAS variables By the way, you placed purge(id0, id1, id2); outside of any program, so this will never be evaluated. Graph 3D | QPI | SolveSys |
|||
02-28-2017, 01:11 PM
Post: #5
|
|||
|
|||
RE: Problems with eval(IdentifierName,#recall)
(02-28-2017 12:43 PM)Han Wrote: You delete Home variables using: DelHVars("name") or DelHVars({ "list", "of", "names" }); Ok, Han but if I include the sentence DelHVars({"id0", "id1", "id2"});, the simulator enters an indefinite cycle. without DelHVars({"id0", "id1", "id2"}); within of the prgm, the EVAL command must first evaluate the local and non-global variables, please try the following 6: goto HOME VIEW 6.1: purge(id0, id1, id2); [ENTER] 6.1a:DelHVars({"id0", "id1", "id2"}); [ENTER] 6.2: Now if you define variables in HOME VIEW id0:=8; id1:='id0'; id2:='id1';[ENTER] // store id2,id1,id0 in the HOME environment 7: goto CAS VIEW 7.1: RCLidsCAS(); [ENTER] returns [8, 8, id2, id1, id0, 8, 8] Why? PHP Code: #cas |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)