nerdamer icon indicating copy to clipboard operation
nerdamer copied to clipboard

How to clear defined functions ?

Open SomebodyLikeEveryBody opened this issue 3 years ago • 2 comments

Hello,

as it is possible to declare variables with

nerdamer.setVars('x', '42');

and forget it with

nerdamer.clearVars();

how can we forget functions we declared using,

nerdamer.setFunction('f'. ['x'], 'x^2');

is there any nerdamer.clearFunctions() feature ?

Thank you !

SomebodyLikeEveryBody avatar Feb 15 '22 21:02 SomebodyLikeEveryBody

@SomebodyLikeEveryBody, you're right. There isn't a prescribed way of achieving this. Something that may have to be looked into. In the meantime, deleting it from the functions list in the parser should do.

// Set a new function
nerdamer.setFunction('f', ['x'], 'x^2');

// It works
console.log(nerdamer('f(x^6)').toString())

// Delete the function "f" from the functions list in the parser
delete nerdamer.getCore().PARSER.functions.f

// It's gone
console.log(nerdamer('f(x^6)').toString())

jiggzson avatar Feb 16 '22 01:02 jiggzson

@jiggzson Thank you very much !

SomebodyLikeEveryBody avatar Feb 18 '22 20:02 SomebodyLikeEveryBody