Skip to content

Conversation

@mrtwistor
Copy link
Contributor

Added missing Delete command.

return Expression('List', *results)

def del_part(expr,indices,evaluation):
def del_one(cur,pos):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it really necessary to put a function inside a function?

Copy link
Contributor Author

@mrtwistor mrtwistor Jul 10, 2019

Choose a reason for hiding this comment

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

I wouldn't say it's "necessary", no. But these are just helper functions that are not intended to be called outside the function del_part, so they are local to that scope, and the same idiom is used elsewhere in the lists.py source (e.g., in get_part, set_part, and Array.apply)

I've now put all three helper functions into the Delete object. Is that better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that better?

I believe so.

return cur
else:
raise PartRangeError
def del_rec(self, cur, rest):
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, I missed this.

def del_rec(self, cur, rest):
if cur.is_atom():
raise PartDepthError
if len(rest)>1:
Copy link
Contributor

Choose a reason for hiding this comment

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

Spaces around >.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

raise PartRangeError
else:
return self.del_one(cur, rest[0])
def del_part(self, expr,indices,evaluation):
Copy link
Contributor

Choose a reason for hiding this comment

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

And here should be a newline too.

@suhr
Copy link
Contributor

suhr commented Jul 11, 2019

@wolfv

@wolfv wolfv merged commit 0018994 into mathics:master Jul 12, 2019
@wolfv
Copy link
Member

wolfv commented Jul 12, 2019

Great! Fantastic contribution.

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