Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

How to clear defined functions ? #658

Open
SomebodyLikeEveryBody opened this issue Feb 15, 2022 · 2 comments
Open

How to clear defined functions ? #658

SomebodyLikeEveryBody opened this issue Feb 15, 2022 · 2 comments

Comments

@SomebodyLikeEveryBody
Copy link

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 !

@jiggzson
Copy link
Owner

@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())

@SomebodyLikeEveryBody
Copy link
Author

@jiggzson Thank you very much !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants