43 Commits

Author SHA1 Message Date
Max Bruckner
aa7ca9178f Implement 'all' parenthesis option 2015-05-08 09:07:15 +02:00
Max Bruckner
c6f22e3663 unskip tests that were broken by parsing parenthesis nodes 2015-05-07 12:06:37 +02:00
Max Bruckner
5767f1f912 OperatorNode: Fix bug from wrong use of getIdentifier
1+(1+1) with parenthesis set to 'auto' triggered a bug because
getPrecedence gets the precedence of the content of a node, but
getIdentifier still returns the 'ParenthesisNode' identifier in case of
a ParenthesisNode.
2015-05-07 12:04:53 +02:00
Max Bruckner
dd0a5e3a68 Parse parentheses into ParenthesisNodes 2015-05-07 10:12:41 +02:00
Max Bruckner
390a0060b4 Add is<NameOfNode> property to enable type checking across constructors 2015-04-28 09:14:53 +02:00
jos
d3d3212633 Refactored all nodes into factory functions (see #342) 2015-04-26 21:25:31 +02:00
Max Bruckner
55a66aeaaf OperatorNode.toTex: get rid of unnecessary curly braces 2015-04-19 09:49:09 +02:00
Max Bruckner
8db07e23ad OperatorNode.toTex: BUGFIX: make clear where the exponent belongs to
Without proper parentheses it's impossible to decide whether an exponent
belongs to the numerator of a fraction or to the entire fraction.

For ConditionalNode, the exponent is hard to see without parentheses.
2015-04-19 02:11:20 +02:00
Max Bruckner
f2bcfed89f LaTeX: no spaces between operands and operators 2015-04-17 14:18:24 +02:00
Max Bruckner
7c1c9c0cef Show less unnecessary parentheses in LaTeX output
OperatorNodes with exponentiation, fractions and conditions use less
parentheses.
2015-04-16 22:31:02 +02:00
Max Bruckner
dacf9fba46 OperatorNode: bugfix: toTex creates invalid LaTeX
toTex has been creating invalid LaTeX for fractions where the operands
are in parenthesis, see '(1+1)/2' for example
2015-04-05 14:29:15 +02:00
Max Bruckner
5dcb87aeaa util/latex: Remove unused functions
* toArgs
* addBraces
* dots and curly functions

util/latex.js: Remove Function addBraces

util/latex.js remove dots and curly functions
2015-04-05 14:29:09 +02:00
Max Bruckner
13e35217b7 Latex restructure 2015-04-05 14:25:54 +02:00
Max Bruckner
47f76f35ac Limit custom toTex with multiple callbacks to FunctionNodes
Now only FunctionNode's toTex can be overwritten mit a map of callbacks
2015-03-17 18:14:14 +01:00
Max Bruckner
0fee9173c8 Enable custom toTex functions 2015-03-13 21:23:14 +01:00
Max Bruckner
b2d868c2ed Update OperatorNode's toTex to better handle parens
Use the new infrastructure in OperatorNode's toTex
2015-03-01 16:34:09 +01:00
Max Bruckner
1ac3319656 OperatorNode: validate input 2015-03-01 10:35:03 +01:00
Max Bruckner
0e5a6e5a38 New generic toString for OperatorNode 2015-03-01 10:35:03 +01:00
Max Bruckner
d593e749e9 New function getIdentifier() for Nodes
getIdentifier() returns a String that contains the name of the node and
the function associated with it ( in case of FunctionNode and
OperatorNode ).
2015-03-01 10:35:03 +01:00
Max Bruckner
e587f0ce00 New tests for Operator mode
* Factorial of Operator node
* Test unaryMinus with sums and differences
* Test OperatorNode that substracts an OperatorNode
2015-02-14 16:31:05 +01:00
jos
309bf3938d Added proper error messages to Node.map 2014-11-15 13:32:02 +01:00
jos
9257ec3c33 Added unit tests for Node.map and Node.forEach 2014-11-15 13:16:32 +01:00
jos
a1f60db0d1 Created Node.map, changed traverse to use Node.map 2014-11-14 11:25:48 +01:00
jos
be9a8629ea Node.transform does not create a clone of the tree anymore 2014-11-13 22:01:48 +01:00
jos
72a1b03850 Documented expression tree API. Some internal refactoring in nodes. 2014-11-12 22:30:15 +01:00
jos
bd1981ecd0 Renamed Node.map and Node.forEach back to traverse and transform 2014-10-13 21:42:48 +02:00
jos
238281e28a Renamed traverse and transform to forEach and map 2014-10-12 19:32:51 +02:00
jos
ba70c07509 Added unit tests for Node.clone 2014-10-11 22:29:48 +02:00
jos
95a49fe156 Node.transform first clones the node tree 2014-10-11 21:59:47 +02:00
jos
839e596772 Implemented transform and traverse 2014-10-11 18:03:41 +02:00
jos
5f08307391 Implemented a function replace for nodes of a parsed expression. 2014-10-11 15:33:23 +02:00
jos
8a12c8e9bc Fixed #200: A new instanceof of math.js must now be created as math.create([options]) instead of math([options]) 2014-08-03 21:42:12 +02:00
jos
7c761e390a Refactored ConstantNode to make it more flexible to various types of input 2014-06-23 11:51:01 +02:00
jos
ced18ecfca Implemented functions dotEqual and dotUnequal, renamed functions smallereq to smallerEq and largereq to largerEq (all functions are now camelcase) 2014-06-09 14:07:21 +02:00
jos
abf1b02ee9 Renamed function unary to unaryminus. Documented and tested constant phi. 2014-06-08 20:12:07 +02:00
Niels Heisterkamp
086e59061a Fixed test and removed remaining console.log. 2014-05-19 20:32:25 +02:00
Niels Heisterkamp
b7fe0bfbf1 Added LaTeX conversion of expressions using toTex() on expression.
Also added some basic tests, which cover some use cases; but should be expanded.
2014-05-19 08:20:06 +02:00
jos
1189efd4d8 Added property type to all expression nodes in a node tree. 2014-04-24 20:26:51 +02:00
josdejong
b046c7ee98 Completed unit tests for all expression nodes 2014-03-01 15:55:20 +01:00
josdejong
42548e1cf0 More unit tests 2014-02-28 22:50:46 +01:00
josdejong
5d96ce4c16 Removed old code for expression evaluation 2014-01-07 21:07:43 +01:00
josdejong
00e55b917e Replaced eval with compile 2014-01-07 16:12:57 +01:00
josdejong
f6acb12e4d Implemented expression compilation for 80% 2014-01-01 20:46:30 +01:00