Writing a counter function

Shlomi Fish shlomif@vipe.technion.ac.il
Sat, 29 Jun 2002 18:23:27 +0300 (IDT)


On Sat, 29 Jun 2002, Mark Carroll wrote:

> On Sat, 29 Jun 2002, Shlomi Fish wrote:
> (snip)
> > counter n = (n,(counter (n+1)))
> (snip)
>
> This doesn't work because you seem to be defining an infinitely deep tuple
> (1,(2,(3,(4,(....))))) which is naughty.
>
> I'm not really sure what alternative to suggest beyond [n .. ] without
> knowing more about what you are trying to do.
>

Actually, I'd like a more generalized counter. Something that would return
both the number and a handler to add another number, which in turn would
return the new sum and a new handler, etc.

Regards,

	Shlomi Fish

> -- Mark
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



----------------------------------------------------------------------
Shlomi Fish        shlomif@vipe.technion.ac.il
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       shlomif@iglu.org.il

He who re-invents the wheel, understands much better how a wheel works.