-
-
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
Add context flag multiplyRightToLeft #481
Add context flag multiplyRightToLeft #481
Conversation
Add a context flag `multiplyRightToLeft` with default value `0` that does not change existing behavior, and also document this feature. Many textbooks use the convention that permutations are functions that are composed from right-to-left, which is why this feature is useful for problem authors. Adding this flag should not affect any of the existing webwork problems that use this macro because the default behavior (multiply left-to-right) is the same as before. For instance, we have `(1 2 3)(1 2) = (2 3)` with the default setting `multiplyRightToLeft=>0`, whereas we have `(1 2 3)(1 2) = (1 3)` when `multiplyRightToLeft=>1`.
Here is some code that exhibits the changes.
|
This looks OK to me. I did some testing, and it seems to work fine. I was not initially sure the canonical representation would work, but it does seem to. |
There is one issue, though. When
|
@paultpearson, I've made a PR to your branch that fixes the problem you point out with the presentation being reversed. It turns out that your modification is in the routine that puts the cycles into the permutation (not the one that actually performs the multiplication), so that is causing the reversal of the order. The |
Fix problem with RTL multiplication, and make it apply to numbers on the right
I think this now works as it should. But since I contributed to the PR, I don't think my approval is sufficient for review. Someone else will want to try it out and review the PR. |
This seems to be working as it should. I wrote a test problem that generates random permutations that are products of 3 cycles and saw it behave as expected.
Only strange behavior is with the checker, but does not seem related to this PR: if canonical representation is a cycle, then the answer checker gives an error like |
Thanks everyone. I'll merge this request. |
Add a context flag
multiplyRightToLeft
with default value0
that does not change existing behavior, and also document this feature. Many textbooks use the convention that permutations are functions that are composed from right-to-left, which is why this feature is useful for problem authors. Adding this flag should not affect any of the existing webwork problems that use this macro because the default behavior (multiply left-to-right) is the same as before. For instance, we have(1 2 3)(1 2) = (2 3)
with the default settingmultiplyRightToLeft=>0
, whereas we have(1 2 3)(1 2) = (1 3)
whenmultiplyRightToLeft=>1
.