-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Fix arithmetic format #892
base: master
Are you sure you want to change the base?
Conversation
Rework arithmetic format
. | ||
. Format[Dice[n_Integer ? (1 <= #1 <= 6&)], OutputForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{Plus[1, Times[-1, p]], Plus[1, Times[-1, p]]}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, Plus[1, Times[-1, p]]}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{Plus[1, Times[-1, p]], p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{Plus[1, Times[-1, p]], 0.5}, r]}]}, ImageSize -> Tiny]] |
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 not perfect, but at least I got something less weird than what we have in master.
# Force parenthesis by adjusting the surrounding context's precedence value, | ||
# We can't change the precedence for the number since it, doesn't | ||
# have a precedence value. | ||
element_prec = 480 |
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 am pretty sure this is not the right way to fix this. There is always a precedence for all atoms.
You were going to come up with a proof of concept by writing MakeBox in Mathics3. |
This PR is a first step to improving the way in which arithmetic expressions are formatted. I started trying to fix how
DirectedInfinity
expressions are formatted, using the standard syntax of WL. However, on each attempt to do that, I collide against the flawed design of our formatting system.At this point, this is getting large, and still there is a lot of work to do. However, with these changes many expressions are formatted in a closer way than in WMA, and I did some steps in order to disentangle the code.
I will leave this here as a draft for a while.