-
Notifications
You must be signed in to change notification settings - Fork 7
Derivative #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Derivative #53
Conversation
Leibniz notation is going to be hard to handle within the parser. I would suggest parsing
And then performing a transform on the AST that converts fractions that look like |
suite('nthRoot', [ | ||
'nthRoot(x)', | ||
'nthRoot(x, 3)', | ||
'nthRoot(8, 3)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup
@@ -211,7 +220,7 @@ class Parser { | |||
|
|||
if (args.length > 1) { | |||
return build.applyNode('add', args.map(term => | |||
term.addParens ? build.parensNode(term) : term)) | |||
term.addParens ? build.parensNode(term) : term)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this formatting change adds anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
@@ -272,7 +280,7 @@ class Parser { | |||
|
|||
return factors.length > 1 | |||
? build.applyNode('mul', factors, {implicit: true}) | |||
: factors[0]; | |||
: factors[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry! It's an issue with my text edit and the auto configs I have. Will fix
|
||
// Lagrange notation | ||
// e.g. f', f'', f'(x) | ||
if (node.name === 'f' && matches(this.currentToken(), `'`)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty restrictive. We should be able to parse the derivative of any function (or expression). This is so we can handle things like (af + bg)'
.
Working on derivative parsing.