You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rules for how . is parsed are arcane. Here are my private notes on the subject from last summer:
1//..9 is ReplaceRepeated[1, 0.9`] 1//.9 is ReplaceRepeated[1, 9] should be 0.9[1] 1/.9 is Times[1, Power[0.9`, -1]] 1...9 is 9 ((1)...) or Hold[Times[RepeatedNull[1], 9]] 7//.9 is ReplaceRepeated[7, 9] 7// .9 is 0.9`[7] 1/.1->2 is 10. -> 2
7// .9 is 0.9`[7]
b; 7`b is 7. b _.1 is Times[Optional[Blank[]], 1]
Rule: If . can be interpreted as part of an operator, it will be. The only exceptions are:
b=.1
a/:b=.1
a/.1
a.b (* The Dot operator. *)
This places the precedence of the decimal point between //. and /.—excepting for the Dot operator itself.
In mathics/Mathics#989 it was noticed that
1/.2
Is comes outReplaceAll[1,2]
rather thanTimes[1,Power[.2,-1]]
.The fix there was to add a lookahead pattern for a number to distinguish these.
ANTLR4 has such a notion too which I think is called a semantic predicate or
{...}?
which might help the parser here.The text was updated successfully, but these errors were encountered: