Skip to content

Update chapters/arrays/zip-function.md #62

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

Merged
merged 1 commit into from
Nov 6, 2012

Conversation

fulmicoton
Copy link
Contributor

Using the max length of the list arguments does not match python
specification of zip. I guess that's ok if we make the behavior in this
boundary case clear.

Using the max length of the list arguments does not match python
specification of zip. I guess that's ok if we make the behavior in this
boundary case clear.
@dbrady
Copy link
Member

dbrady commented Nov 6, 2012

Paul,

Good spot--this may be a case of Ruby influence vs. Python influence and which one makes the most sense. In Python, zip takes a list of arrays, like so: zip(ray1, ray2, ray3) and zips them to an n-element array where n is the length of the shortest array being zipped. In ruby, zip is a method ON array, like so: ray1.zip(ray2, ray3) and it returns an array of the same length as ray1. So it would truncate arrays that are longer than ray1 and insert nils into arrays that are shorter.

Since this zip method is a global method rather than an instance method, this "feels" like a Python method and makes perfect sense.

Merging commit, and granting commit bit.

Thanks, keep 'em coming!

David

P.S. Wait, no, it's not a case of Ruby influence at all. max() is just the wrong method to call here. I'm overthinking this, it's just a regular bug. YOUR work is still impeccable, I'm just a pompous windbag. :-) Thanks again!

dbrady added a commit that referenced this pull request Nov 6, 2012
Update chapters/arrays/zip-function.md
@dbrady dbrady merged commit ca8c051 into coffeescript-cookbook:master Nov 6, 2012
@fulmicoton
Copy link
Contributor Author

Thanks for the merge. I wondered which spec felt "right". One tiny little detail I like about python's version is that I can do zip(l,l[1:]) to get the list of pairs of two successive elements.

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.

2 participants