
I adjunt some code that i supose is what are you locking for.
Is based in a previous message (by jefu on 13 of june) idea from the
"Haskell acumulator" thread.
the "prueba" function is the translation of your example.
By the way, what's the purpose of this coding? (this is the type of
question: "ok, I have a hammer, now, for what kind of nail it is useful?")
Cheers,
Luis Michelena
----- Original Message -----
From: Shlomi Fish
On Sat, 29 Jun 2002, Hannah Schroeter wrote:
Hello!
On Sat, Jun 29, 2002 at 06:23:27PM +0300, Shlomi Fish wrote:
[...]
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.
That's just what lazy lists are for. The "handler" thing is done automatically thanks to lazy evaluation.
I.e. countFrom n = n : countFrom (n + 1) or just countFrom n = [n..]
No. But I want to generate an irregular series, which I determine the intervals between two consecutive numbers myself. E.g:
let (num1, next1) = (counter 5) (num2, next2) = (next1 100) (num3, next3) = (next2 50) in [num1,num2,num3]
Will have the numbers [5, 105, 155].
Regards,
Shlomi Fish
Kind regards,
Hannah. _______________________________________________ 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.