[Haskell-cafe] Course-of-value recursion by defining a sequence as a self-referential infinite list

Douglas McIlroy douglas.mcilroy at dartmouth.edu
Mon Jan 20 13:54:31 UTC 2025


> catalanNumbers :: Num a => [a]
> catalanNumbers =
>   let xs = 1 : PowerSeries.mul xs xs
>   in  xs

This example of a generating function come to life as a program deserves to
be better known. Bill Burge presented it 50 years ago in "Recursive
Programming Techniques", Addison-Wesley, 1975. I revisited it in "Power
series, power serious", JFP 9 (1999) 323-335, where, with overloadied
arithmetic, it became
      ts = 1 : ts^2
The technique is laid bare in ten one-liners at
https://www.cs.dartmouth.edu/~doug/powser.html.

Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20250120/9dfd292b/attachment.html>


More information about the Haskell-Cafe mailing list