Skip to content

Two similar Set[] patterns matching differently in Mathics3 and wolframscript #1233

Open
@rocky

Description

Description

These two Set assignments, when they exist together, seem to match differently in Mathics3 than in wolframscript:

Bug[n_Integer,_] := Print["Negative ", n] /; (n<0)
Bug[n_Integer,maxpart_Integer] := Print["Integer ", n]

How to Reproduce

In mathics:

In[1]:= Bug[n_Integer,_] := Print["Negative ", n] /; (n<0)
Out[1]= None

In[2]:= Bug[-5, 3]
Negative -5
Out[2]= None

In[3]:= Bug[n_Integer,maxpart_Integer] := Print["Integer ", n]
Out[3]= None

In[4]:= Bug[-5, 3]
Integer -5
Out[4]= None

In wolframscript:

In[1]:= Bug[n_Integer,_] := Print["Negative ", n] /; (n<0)                                    

In[2]:= Bug[-5, 3]                                                                            
Negative -5

In[3]:= Bug[n_Integer,maxpart_Integer] := Print["Integer ", n]                                

In[4]:= Bug[-5, 3]                                                                            
Negative -5

What's going on, and why?

Expected behavior

The wolframscript behavior

Workarounds

In combinatoria V0.9 basically the two Set statements were combined into one Set statement with an explicit If test.

Additional context

Noticed in getting Combinatorical V0.9's Partitions[] function working.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions