3 ms·
Tangentially, the Löb function over (Haskell) functors implements spreadsheet-like computations in an unexpected way: https://github.com/quchen/articles/blob/ma
by rfw 11y ago
Tangentially, the Löb function over (Haskell) functors implements spreadsheet-like computations in an unexpected way: https://github.com/quchen/articles/blob/master/loeb-moeb.md https://github.com/quchen/articles/blob/master/loeb-moeb.md
ex.
loeb [const 1,
const 2,
\xs -> x !! 0 + x !! 1]
gives you [1, 2, 3].
Naturally, it doesn't allow for mutations or anything fancy, but it is an interesting curiosity.
- masklinn 11y agoIt basically works the same way the "self-referential" fib does, doesn't it? fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
- art-w 11y agoNot exactly: you don't get the O(1) access to the two previous computations with loeb. It abstracts the collection used for memoization, but it doesn't provides "locality". Here's a presentation that dives into loeb and expands it to a comonadic fixpoint that lets you do the fibs example correctly: https://www.youtube.com/watch?v=F7F-BzOB670 https://www.youtube.com/watch?v=F7F-BzOB670
- bodhi 11y agoHere's another reference: http://blog.sigfpe.com/2006/11/from-l-theorem-to-spreadsheet.html http://blog.sigfpe.com/2006/11/from-l-theorem-to-spreadsheet... (I completely missed your GitHub link the first time I read this comment)
- cousin_it 11y agoIsn't that the same as using vanilla laziness: > let xs = [1, 2, (xs !! 0) + (xs !! 1)] in xs [1, 2, 3] It's order independent as well: > let xs = [(xs !! 1) - 1, (xs !! 2) - 1, 3] in xs [1, 2, 3] Why do you need loeb?
- rfw 11y agoI guess it finds fixed points over a functor without requiring you to have a reference to the functor (having about the same usefulness as `fix`).