diff options
Diffstat (limited to 'lib/utils.coffee')
| -rw-r--r-- | lib/utils.coffee | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/utils.coffee b/lib/utils.coffee index e89d0aa2..c997b74b 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -126,6 +126,14 @@ Utils = return 1 0 + # Zip two (or more) arrays: + # - Utils.zip([ [a,b], [1,2] ]) returns [ [a,1], [b,2] ] + # - Length of result is `arrays[0].length`. + # - Adapted from: http://stackoverflow.com/questions/4856717/javascript-equivalent-of-pythons-zip-function + zip: (arrays) -> + arrays[0].map (_,i) -> + arrays.map( (array) -> array[i] ) + # This creates a new function out of an existing function, where the new function takes fewer arguments. This # allows us to pass around functions instead of functions + a partial list of arguments. Function::curry = -> |
