Pure recursively defined sets without looping in Haskell
joachim-breitner.de
joachim-breitner.de
Btw, regarding the introductory example
> fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
I prefer the more straightforward
fibs = f 0 1 where f a b = a : f b (a+b) fib n = head (apply (Matrix [[0,1], [1,1]] ^ n) [0,1])
https://wiki.haskell.org/The_Fibonacci_sequencehttps://en.wikipedia.org/wiki/Fibonacci_number#Matrix_form
Faster Haskell implementations exist as shown on the Haskell page link, but the idea was to show the most straightforward form that is also recursive with an order of magnitude better runtime.
The title simply engages my pedantic self and makes me want to point out that tail recursion == looping and, really, that recursion is looping.
You could implement loops with recursion, but I wouldn't call manual recursion a loop.
Similarly I wouldn't call a manual "goto" a function call, even if one way you'd implement function calls could be with goto.
The title does use a bit of shorthand, as it's aimed at Haskell developers. And any Haskell dev using GHC with enough experience has run into <<loop>> before. So the title isn't wrong; it's just for a different audience.