6 kyu
zipWith
5,068 of 7,259JohanWiltink
Description:
Task
zipWith
( or zip_with
) takes a function and two arrays and zips the arrays together, applying the function to every pair of values.
The function value is one new array.
If the arrays are of unequal length, the output will only be as long as the shorter one.
(Values of the longer array are simply not used.)
Inputs should not be modified.
Examples
zipWith( Math.pow, [10,10,10,10], [0,1,2,3] ) => [1,10,100,1000]
zipWith( Math.max, [1,4,7,1,4,7], [4,7,1,4,7,1] ) => [4,7,7,4,7,7]
zipWith( function(a,b) { return a+b; }, [0,1,2,3], [0,1,2,3] ) => [0,2,4,6] // Both forms are valid
zipWith( (a,b) => a+b, [0,1,2,3], [0,1,2,3] ) => [0,2,4,6] // Both are functions
Input validation
Assume all input is valid.
Lists
Arrays
Functional Programming
Algorithms
Similar Kata:
Stats:
Created | Nov 11, 2016 |
Published | Nov 11, 2016 |
Warriors Trained | 9766 |
Total Skips | 123 |
Total Code Submissions | 21533 |
Total Times Completed | 7259 |
JavaScript Completions | 5068 |
Python Completions | 1074 |
Rust Completions | 133 |
C Completions | 110 |
OCaml Completions | 36 |
Scala Completions | 22 |
Lua Completions | 14 |
Total Stars | 96 |
% of votes with a positive feedback rating | 94% of 802 |
Total "Very Satisfied" Votes | 712 |
Total "Somewhat Satisfied" Votes | 77 |
Total "Not Satisfied" Votes | 13 |
Total Rank Assessments | 9 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |