-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Btw. is it intended that "map([], f(x)=x)" throws the index error (which is fixed now), but the short form "map([], x)" will give a "undefined symbol x" error? "map([], x+1)" was always okay, as it is parsed as a function, and worked even without the fix. Otherwise this short term just seems to be limited, compared with a declared function.
Originally posted by @NilsDietrich in #3564
The above question seems not to have to do with the empty first operand, but simply whether a bare variable is allowed in the "compiled inline expression" in the mathjs expression language parser. Currently, attempting to do so fails with an "undefined symbol" error. So we should either:
- Support a single bare variable as the identity function wherever a "compiled inline expression" is allowed (currently just three places, namely the callback argument of
map,foreach, orfilter), or - Decide that it is not supported and adjust the documentation accordingly, and ideally generate a more specific error message.
I'd say all else being equal, (1) seems preferable, just on the principle of minimizing exceptions to rules. But it is up to @josdejong. If (1) is decided on, this should be changed to a "bug" issue; if (2) then a "documentation" issue.