[Haskell-beginners] howto reason infinite lists

Chaddaï Fouché chaddai.fouche at gmail.com
Mon Jun 21 17:43:13 EDT 2010


On Mon, Jun 21, 2010 at 8:58 PM, prad <prad at towardsfreedom.com> wrote:
> it seems to me that if we consider the list to be already built, we can
> apply zip successively to get the next part of it, but if we think
> recursively we start at the beginning at each recursive level and go
> nowhere.

That's a funny way to say it : to me recursive thinking has always
been about assuming I already have a function that works on smaller
(in some sense) cases, writing the function knowing that and then
figuring what's the base case we're tending toward and handling it
non-recursively. That's what recursion is about for me and I've always
found easier to think about it like that rather than always expansing
the recursive calls (I also find it easier than thinking iteratively
nowadays but YMMV).

In other words what you describe as your new method to think about
infinite structure is the only way I approach recursion (of structure
or functions). I would say it's a perfectly valid approach as long as
you don't forget to handle the base case (here it's the explicit
definition of the first two elements).
-- 
Jedaï


More information about the Beginners mailing list