[Haskell-cafe] Recursion problem in infinite list model
Ryan Ingram
ryani.spam at gmail.com
Thu Mar 27 22:03:40 EDT 2008
Another way to defer the evaluation of the second argument of (-+) is like this:
(-+) :: a -> List a -> List a
x -+ y = List(f) where
f 0 = x
f k = case y of List g -> g (k-1)
This is exactly what the lazy pattern will do at compile-time. Does
this give you a better understanding of how lazy patterns work and why
they fix the problem?
-- ryan
On 3/27/08, Hans Aberg <haberg at math.su.se> wrote:
> On 27 Mar 2008, at 17:51, Luke Palmer wrote:
>
> > A more standard way to do this would be:
> >
> > data List a = List (Ordinal -> a) Ordinal
>
> I used
> data List a = Empty | (Ordinal->a) :+ Ordinal
> which might then be simplified by dropping "Empty".
>
> Hans Aberg
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list