3 ms·
I've been using externally driven recursion quite a lot in some toy programs lately, and it is extremely helpful when profiling different memoization schemes. W
by sordina 16y ago
I've been using externally driven recursion quite a lot in some toy programs lately, and it is extremely helpful when profiling different memoization schemes. Where once you would have had to change a sizable chunk of your explicitly recursive function, now you can simply use combinators to generate different implementations, be it for profiling purposes, or even runtime optimization :)
-- General implementation
type T = Int -> Set [Int]
g :: T -> T
...
g' = fix g -- Very slow
g'' = memoFix integral g -- Fast, Generic
g''' = memoFix integer g -- Fast enough to use
On a side note, the paper seems too readable to me! Usually these kinds of topics are presented in such a way as to make them almost completely incomprehensible. Something must be very wrong here.
[edit: How do you quote code?]
- jacquesm 16y ago> How do you quote code? Double indent with spaces I always figured that the Y combinator was mostly theoretical, when I came across a little javascript memoization demo using the Y combinator a while ago I changed my mind on that. Very interesting stuff this, especially because it seems to have some really neat side effects (pun intended), such as making some of the most naive code run in linear time.