0
math.eval(["c = b" , "a = b + c"] , {"a" : 1, "b" : 2})
[2, 4]

Switching the order of the expressions,

math.eval(["a = b + c" , "c = b"] , {"a" : 1, "b" : 2})
Error: Undefined symbol c

Setting initial value for c to NaN

math.eval(["a = b + c" , "c = b"] , {"a" : 1, "b" : 2, c: NaN})
[NaN, 2]

Is math.js capable of evaluating expressions in a topological order ?

haki
  • 9,389
  • 15
  • 62
  • 110

1 Answers1

1

No, math.js just evaluates the expressions sequentially.

Support for symbolic computations would be really nice though... See these related discussions on github.

Jos de Jong
  • 6,602
  • 3
  • 38
  • 58
  • I've managed to achieve that with dirty checking (which is basically iterating through the expression list till you get no new results) but i was more interested if there is an underlying tree structure. Thanks. – haki Jan 05 '14 at 14:18