-
-
Notifications
You must be signed in to change notification settings - Fork 205
Added Delete command #784
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
Added Delete command #784
Conversation
mathics/builtin/lists.py
Outdated
| return Expression('List', *results) | ||
|
|
||
| def del_part(expr,indices,evaluation): | ||
| def del_one(cur,pos): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, I missed this.
mathics/builtin/lists.py
Outdated
| def del_rec(self, cur, rest): | ||
| if cur.is_atom(): | ||
| raise PartDepthError | ||
| if len(rest)>1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces around >.
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
|
Great! Fantastic contribution. |
Added missing Delete command.