Mathics3 / mathics-core

An open-source Mathematica. This repository contains the Python modules for WL Built-in functions, variables, core primitives, e.g. Symbol, a parser to create Expressions, and an evaluator to execute them.

Home Page:https://mathics.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go over Operator Precedence

rocky opened this issue · comments

Description

Go over Operator precedence. Possibly this is an activity in mathics scanner where we create new operator tables which include: Precedence[], and the actual precedence, taking into account affix and arity of the operator. See also https://wltools.github.io/LanguageSpec/Specification/Syntax/OperatorTableHTML/

How to Reproduce

In WMA, the right value for the precedence would be exactly the same as Times (400):

In[1]:= Times[b, PrecedenceForm[3 A ,400]]                                                                                                                                    

Out[1]= b (3 A)

In[2]:= Times[b, PrecedenceForm[3 A ,401]]                                                                                                                                    

Out[2]= b 3 A

In Mathics, this does not works in the same way:

In[1]:= Times[b, PrecedenceForm[3 A ,400]]                                                                                                                                    

Out[1]= b (3 A)

In[2]:= Times[b, PrecedenceForm[3 A ,401]]                                                                                                                                    

Out[2]= b (3 A)

In[2]:= Times[b, PrecedenceForm[3 A ,399]]                                                                                                                                    

Out[2]= b (3 A)

but

In[1]:= Times[b, PrecedenceForm[A ,400]]                                                                                                                                    

Out[1]= b A

In[2]:= Times[b, PrecedenceForm[3 A ,401]]                                                                                                                                    

Out[2]= b A

In[2]:= Times[b, PrecedenceForm[3 A ,399]]                                                                                                                                    

Out[2]= b (A)

Additional context

The above example is extracted from #809 (comment) and #810