Page 1 sur 1

Define function cmd

Publié : mer. avr. 28, 2021 10:19 pm
par compsystems
Hello
I want to define a function where the expression is stored in a variable, but it does not call the content of the variable

expr1 := 'x^3 - 2*x^2 + 1*x -1'; [enter] x^3-2*x^2+1*x-1
function f(x)=expr1; end; [enter] (x)->nop(expr1) excepted (x)->x^3-2*x^2+1*x-1
function f(x) expr1; end;
f := function(x) expr1; end;
f:=(x) -> expr1;
f(x):=expr1;
f(x):=eval(expr1);

http://www-fourier.ujf-grenoble.fr/~par ... fr297.html

Re: Define function cmd

Publié : jeu. avr. 29, 2021 2:57 pm
par parisse
I don't understand what you want to do. If you want to define a function from an expression, the command is unapply. For example
g:=x^2-1;
f:=unapply(g,x);

Re: Define function cmd

Publié : jeu. avr. 29, 2021 11:15 pm
par compsystems
ok, "unapply" works fine