Skip to content

How to differentiate between variables and functions #1783

@tannakartikey

Description

@tannakartikey

I want to extract all the variables from a formula.

I am traversing through the Expression Tree using the traverse method to get all the SymbolNodes.

The problem is that the functions like sqrt, pi, sin are considered as SymbolNode.

Is there any way I can ignore all those values? Right now I am doing the following to differentiate them:

typeof math[node.name] === 'function' ? 'This is function' : 'This is symbol'

The pi is not a function either.

I want to do this so that I can ask the user for those values and then set the scope using the user input to evaluate the formula.

Is there any better way to handle this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions