6 kyu
Fun with lists: map
949 of 1,697janitormeir
Description:
Implement the method map, which accepts a linked list (head) and a mapping function, and returns a new linked list (head) where every element is the result of applying the given mapping method to each element of the original list.
For example:
Given the list: 1 -> 2 -> 3
, and the mapping function x => x * 2
, map should return 2 -> 4 -> 6
The linked list is defined as follows:
function Node(data, next = null) {
this.data = data;
this.next = next;
}
Note: the list may be null and can hold any type of value.
Good luck!
This kata is part of fun with lists series:
Lists
Functional Programming
Fundamentals
Similar Kata:
Stats:
Created | Nov 11, 2016 |
Published | Nov 11, 2016 |
Warriors Trained | 4474 |
Total Skips | 381 |
Total Code Submissions | 9272 |
Total Times Completed | 1697 |
JavaScript Completions | 949 |
Java Completions | 443 |
PHP Completions | 73 |
C# Completions | 208 |
C Completions | 73 |
Total Stars | 90 |
% of votes with a positive feedback rating | 92% of 342 |
Total "Very Satisfied" Votes | 297 |
Total "Somewhat Satisfied" Votes | 36 |
Total "Not Satisfied" Votes | 9 |
Total Rank Assessments | 8 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |