Skip to content

Commit

Permalink
Merge pull request coffeescript-cookbook#42 from paulrosenzweig/master
Browse files Browse the repository at this point in the history
Use CoffeeScript Idioms
  • Loading branch information
blowmage committed Apr 14, 2012
2 parents 33bdc37 + bbfcdd9 commit 5f29cec
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions chapters/arrays/zip-function.md
Expand Up @@ -15,15 +15,9 @@ Use the following CoffeeScript code:
# Usage: zip(arr1, arr2, arr3, ...)
zip = () ->
lengthArray = (arr.length for arr in arguments)
length = Math.max.apply(Math, lengthArray)
argumentLength = arguments.length
results = []
length = Math.max(lengthArray...)
for i in [0...length]
semiResult = []
for arr in arguments
semiResult.push arr[i]
results.push semiResult
return results
arr[i] for arr in arguments

zip([0, 1, 2, 3], [0, -1, -2, -3])
# => [[0, 0], [1, -1], [2, -2], [3, -3]]
Expand Down

0 comments on commit 5f29cec

Please sign in to comment.