Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Nov 6, 2012

Conversation

Projects
None yet
2 participants
Contributor

fulmicoton commented Nov 6, 2012

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.

@fulmicoton fulmicoton Update chapters/arrays/zip-function.md
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.
e19a815
Owner

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 dbrady added a commit that referenced this pull request Nov 6, 2012

@dbrady dbrady Merge pull request #62 from poulejapon/patch-2
Update chapters/arrays/zip-function.md
ca8c051

@dbrady dbrady merged commit ca8c051 into coffeescript-cookbook:master Nov 6, 2012

Contributor

fulmicoton commented Nov 6, 2012

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