Post Reply 
Create function by program and store as variable ?
09-25-2015, 11:13 PM (This post was last modified: 09-25-2015 11:15 PM by xset.)
Post: #1
Create function by program and store as variable ?
I've tried to define function in EVAL(EXPR(...)) environment.
Something like:
LOCAL fnstr:="MyFn(x) BEGIN PRINT(x); END;";
LOCAL fn:=EVAL(EXPR(fnstr));
fn(33);


All I got was declaration and printing of local variable: EVAL(EXPR("LOCAL mvar:=33; PRINT(mvar);")) in non-CAS program.

In any mode it doesn't accept lambda expressions or any syntax of function declaration. EVAL returns "Error: Unmatch control word"

But this worked in CAS command line:
(x)->BEGIN PRINT(x); END; works in CAS mode and resulted in function creation (x)->[ PRINT(x); ] which really prints argument when called!

Is any way to parse string with code and create function during execution of program ?

Thanks in advance
XSet
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Create function by program and store as variable ? - xset - 09-25-2015 11:13 PM



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