6 kyu
Concat me like a fold
Description:
The concat
function on lists has the following type:
concat :: [[a]] -> [a]
Simply put, it flattens a list:
concat [[1, 2], [3, 4], [], [5]] == [1, 2, 3, 4, 5]
Farmer Thomas wants to write concat
in terms of foldr
. Specifically, he wants you to find p
, q
and r
such that:
concat = foldr (foldr p q) r
Now get working!
After doing this one, you may want to check out Lambda Calculus: Lists as folds II (this might act as a hint for this kata :P).
Functional Programming
Similar Kata:
Stats:
Created | Jun 15, 2022 |
Published | Jun 15, 2022 |
Warriors Trained | 152 |
Total Skips | 9 |
Total Code Submissions | 105 |
Total Times Completed | 44 |
Haskell Completions | 44 |
Total Stars | 6 |
% of votes with a positive feedback rating | 97% of 18 |
Total "Very Satisfied" Votes | 17 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |