Skip to content
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

Flat attribute of function doesn't automatically applied to every subsequence of arguments #1485

Open
CallmeNezha opened this issue Jul 10, 2021 · 1 comment

Comments

@CallmeNezha
Copy link

Following paragraph is taken from https://reference.wolfram.com/language/tutorial/EvaluationOfExpressions.html.en?source=footer

Attributes like Flat can affect not only evaluation, but also operations such as pattern matching. If you give definitions or transformation rules for a function, you must be sure to have specified the attributes of the function first.
Here is a definition for the flat function f:
In[3]:= f[x_, x_] := f[x] https://wolfram.com/xid/0m5dyglvgmwz4-si8
Because f is flat, the definition is automatically applied to every subsequence of arguments:
In[4]:= f[a, a, a, b, b, b, c, c] https://wolfram.com/xid/0m5dyglvgmwz4-iw6
Out[4]= f[a, b, c]

But in Mathics it was

In[1]:= SetAttributes[f, Flat]
Out[1]= None

In[2]:= f[f[a, b], c]
Out[2]= f[a, b, c]

In[3]:= f[x_, x_] := f[x]
Out[3]= None

In[4]:= f[a, a, a, b, b, b, c, c]
Out[4]= f[a, b, b, b, c, c]
@rocky
Copy link
Member

rocky commented Jul 11, 2021

Mathics is open-source software. Is this something you are interesting in investigating further in the source code to fix?

If not, it certainly helps me prioritize which bugs to look at by understanding what the impact is. Is this something you noticed interactively, or is this bug something that is keeping a package working? If a package it would be useful to know which package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants