Skip to content

Instantly share code, notes, and snippets.

@Dykam
Created February 8, 2011 18:05
Show Gist options
  • Select an option

  • Save Dykam/816870 to your computer and use it in GitHub Desktop.

Select an option

Save Dykam/816870 to your computer and use it in GitHub Desktop.
list = [0...10]
otherList = [0...10]
zip = (arrays...) ->
length = 0
for array in arrays when array.length > length
length = array.length
for i in [0...length]
array[i] for array in arrays
Array::zip = (arrays...) ->
zip this, arrays...
Array::equals = (that) ->
for [a, b] in @zip that when a isnt b
return false
return true
console.log list.equals otherList
console.log list.zip otherList
console.log zip [0,1,2], [4,5,6], [7,8,9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment