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

Stats:

CreatedJun 15, 2022
PublishedJun 15, 2022
Warriors Trained152
Total Skips9
Total Code Submissions105
Total Times Completed44
Haskell Completions44
Total Stars6
% of votes with a positive feedback rating97% of 18
Total "Very Satisfied" Votes17
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes0
Total Rank Assessments6
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • davidmaamoaix Avatar
  • JohanWiltink Avatar
Ad