Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Minor changes #634

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

Closed
wants to merge 1 commit into from
Closed

Minor changes #634

wants to merge 1 commit into from

Conversation

Chipe1
Copy link
Contributor

@Chipe1 Chipe1 commented Aug 25, 2017

Based on the comments in #625

@@ -222,7 +222,7 @@ def prop_symbols(x):
elif is_prop_symbol(x.op):
return {x}
else:
return {symbol for arg in x.args for symbol in prop_symbols(arg)}
return set().union(*map(prop_symbols, x.args))
Copy link
Collaborator

Choose a reason for hiding this comment

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

To be honest, I prefer the comprehension to the set union with the map pointer, since it is much easier to understand (at least for me).

If both are correct, I would change it to the comprehension (which is simpler and stylistically closer to the way we do things in the repository).

That is unless the union is much, much faster or is the most popular way to deal with the problem.

Copy link
Contributor Author

@Chipe1 Chipe1 Aug 25, 2017

Choose a reason for hiding this comment

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

The map method is efficient but I dont think we need to worry about speed as we are using only small expressions. Since it is not directly mentioned in any pseudocode, people could think of it as a simple blackbox function and not really care to look into it. Finally, it's upto @norvig
Maybe we can use both. One in each of the functions :D

@@ -232,7 +232,7 @@ def constant_symbols(x):
elif is_prop_symbol(x.op) and not x.args:
return {x}
else:
return {symbol for arg in x.args for symbol in constant_symbols(arg)}
return set().union(*map(constant_symbols, x.args))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as my above review.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you think the comprehension is easier to understand, let's stick with that.

@norvig norvig closed this Aug 25, 2017
@Chipe1 Chipe1 deleted the suggfoil branch August 25, 2017 16:26
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