4 kyu
Fix it
547 of 552gans
Description:
The fix function can be defined as:
fix :: (a -> a) -> a
fix f = let x = f x in x
If we regard this as a language primitive, any recursive function can be written without using recursion. Write foldr'
and reverse'
as non-recursive functions that can be 'fixed' to foldr
and reverse
as follows:
foldr = fix foldr'
reverse = fix reverse'
For a more detailed explanation of the fix function, see http://en.wikipedia.org/wiki/Fixed-point_combinator
Note: foldr
is lazy, so your foldr'
should be lazy too. Also, your foldr'
need only work on lists - it does not have to work for an arbitrary Foldable
functor.
Fundamentals
Similar Kata:
Stats:
Created | Oct 19, 2014 |
Published | Oct 19, 2014 |
Warriors Trained | 1423 |
Total Skips | 332 |
Total Code Submissions | 2650 |
Total Times Completed | 552 |
Haskell Completions | 547 |
PureScript Completions | 16 |
Total Stars | 89 |
% of votes with a positive feedback rating | 93% of 137 |
Total "Very Satisfied" Votes | 120 |
Total "Somewhat Satisfied" Votes | 14 |
Total "Not Satisfied" Votes | 2 |