Skip to content

Commit 5f29cec

Browse files
committed
Merge pull request coffeescript-cookbook#42 from paulrosenzweig/master
Use CoffeeScript Idioms
2 parents 33bdc37 + bbfcdd9 commit 5f29cec

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

chapters/arrays/zip-function.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@ Use the following CoffeeScript code:
1515
# Usage: zip(arr1, arr2, arr3, ...)
1616
zip = () ->
1717
lengthArray = (arr.length for arr in arguments)
18-
length = Math.max.apply(Math, lengthArray)
19-
argumentLength = arguments.length
20-
results = []
18+
length = Math.max(lengthArray...)
2119
for i in [0...length]
22-
semiResult = []
23-
for arr in arguments
24-
semiResult.push arr[i]
25-
results.push semiResult
26-
return results
20+
arr[i] for arr in arguments
2721

2822
zip([0, 1, 2, 3], [0, -1, -2, -3])
2923
# => [[0, 0], [1, -1], [2, -2], [3, -3]]

0 commit comments

Comments
 (0)