by rfw · 11y ago · 0 comments
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.
http://blog.sigfpe.com/2006/11/from-l-theorem-to-spreadsheet...
(I completely missed your GitHub link the first time I read this comment)
> 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? fibs = 0 : 1 : zipWith (+) fibs (tail fibs)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