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

Guard against running Delete[] on an empty list. #1109

Merged
merged 2 commits into from
Oct 3, 2024
Merged

Conversation

rocky
Copy link
Member

@rocky rocky commented Oct 1, 2024

No description provided.

@mmatera
Copy link
Contributor

mmatera commented Oct 2, 2024

This is what happens in WMA:

In[1]:= Delete[{},0]                                                            

Out[1]= Sequence[]

In[2]:= Delete[{},1]                                                            

Delete::partw: Part {1} of {} does not exist.

Out[2]= Delete[{}, 1]

In[3]:= Delete[{},0]                                                            

Out[3]= Sequence[]

In[4]:= Delete[a,0]                                                             

Delete::partw: Part 0 of a does not exist.

Out[4]= Delete[a, 0]

@axkr
Copy link

axkr commented Oct 3, 2024

This is what happens in WMA:

Which version do you use?

In 14. 1:

In[1]:= Delete[{},0]                                                            
 
Out[1]= Identity[]

Sequence[] is converted to Identity[].

@mmatera
Copy link
Contributor

mmatera commented Oct 3, 2024

This is what happens in WMA:

Which version do you use?

I am using 12.2 and 13.2.0

In 14.1, what happens with

Delete[{1,2,3}, 0]

?

@axkr
Copy link

axkr commented Oct 3, 2024

In 14.1, what happens with

Delete[{1,2,3}, 0]

?

Identity[1,2,3]

because

>> Sequence[1,2,3]

Identity[1, 2, 3] 

@mmatera
Copy link
Contributor

mmatera commented Oct 3, 2024

In 14.1, what happens with

Delete[{1,2,3}, 0]

?

Identity[1,2,3]

because

>> Sequence[1,2,3]

Identity[1, 2, 3] 

Until 13.2.0, Identity just accepted 1 argument. Also I wonder: Is this the "FullForm"? Or just the way in which WMA 14 formats Sequence[...] ?

@axkr
Copy link

axkr commented Oct 3, 2024

Until 13.2.0, Identity just accepted 1 argument. Also I wonder: Is this the "FullForm"? Or just the way in which WMA 14 formats Sequence[...] ?

Not sure. I think it's evaluated in the backend. A General::argx message Identity called with 0 arguments; 1 argument is expected is also printed.

Copy link
Contributor

@mmatera mmatera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rocky rocky merged commit ddf6306 into master Oct 3, 2024
11 checks passed
@rocky rocky deleted the Delete-bug-fix branch October 3, 2024 20:54
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

Successfully merging this pull request may close these issues.

3 participants