Skip to content

Cannot use map function inside evaluate #3238

Answered by dvd101x
WilcovS asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

The syntax for arrow functions in javascript is not the syntax for functions in the parser.

This is not a function x => x+x, instead try f(x) = x+x personally if I wont be using f later I tend to use _(x) = x+x that will make _ into a function but that reminds me I wont be using that later.

You could try the following and get the expected result.

math.evaluate('map([1, 2, 3], _(x) = x+x)')

Here is a reference for defining functions.
https://mathjs.org/docs/expressions/syntax.html#differences-from-javascript

Replies: 1 comment 5 replies

Comment options

dvd101x
Jul 24, 2024
Collaborator Sponsor

You must be logged in to vote
5 replies
@WilcovS
Comment options

@josdejong
Comment options

@dvd101x
Comment options

dvd101x Aug 13, 2024
Collaborator Sponsor

@josdejong
Comment options

@dvd101x
Comment options

dvd101x Oct 1, 2024
Collaborator Sponsor

Answer selected by WilcovS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants