-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Make function parenPrecedence greater than unary negative, postive #487
Conversation
Is this something that we want to target for ww-2.16? I think it is a small change, and is a nice aesthetic improvement. Note that there is another instance in which parentheses are rendered where they are not needed as well. That is the case that parserAssignment.pl is used. Things like |
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.
The change works for me, and I think it is a good improvement.
I think this can be merged for WW 2.16.
@dvpc - Any comments on potential adverse effects of the change to precedence.
I labeled as |
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 think this is a good change. @dpvc suggested it to @Alex-Jordan, although it would be good to get his official review. I am not sure how in depth he had thought it out when he suggested it.
The develop branch needs to be merged in again to the PR. I'm not able to view anything because of the discrepancy between MathJax 2.7.X (which is in this PR) and 3.X which is develop. |
@pstaabp: You can merge the develop branch into the pull request branch after checking it out. It is not necessary to merge the develop branch into this pull request. That should become part of your workflow when testing pull requests. |
@drgrice1 good call. I was trying figure out how I could test with Alex doing this. |
Overall, looks good.
I would agree with adding this as well, but we can do that at a later time. I noted that |
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 approve.
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 should cause any problems.
This is unrelated to the function application precedence, and can be controlled by the Context()->flags->set(showExtraParens=>0); but this will also remove other extra parentheses that make operator-operand connections painfully clear. I've also made a pull request that will prevent these particular parentheses when |
I have tried setting the |
This test loadMacros("parserAssignment.pl");
Context("Numeric")->flags->set(showExtraParens => 0);
parser::Assignment->Allow;
TEXT(Formula("x = -3")->string); produces |
Yes, but if the student enters loadMacros("PGstandard.pl", "MathObjects.pl", "PGML.pl", "parserAssignment.pl");
Context("Numeric")->flags->set(showExtraParens => 0);
parser::Assignment->Allow;
$f1 = Formula("x = -3");
BEGIN_PGML
Enter [`[$f1]`]: [______]{$f1}
END_PGML |
Sorry, the answer checker sets |
Yeah, I see that now. Well, your pull request works for student answers also. |
This may be controversial, so consider this PR as up for discussion.
In the forums, there is this thread: https://webwork.maa.org/moodle/mod/forum/discuss.php?d=4790
Prior to this commit,
Formula("-sqrt(x)")
will render as-\left(\sqrt{x}\right)
because the function application has lower precedence than negation. The commit changes that, so that this example renders as-\sqrt{x}
. And similarly for any-function(x)
.I can't think of a reason to keep it the way it is. The change seems to me to be an aesthetic improvement. And also a pedagogical improvement, since occasionally we get students wondering why WW is printing those parentheses, and asking if they are needed. Of course, I may be missing something.