Writing a counter function
Sat, 29 Jun 2002 18:03:01 +0100
Shlomi Fish wrote:
> No. But I want to generate an irregular series, which I determine the
> intervals between two consecutive numbers myself. E.g:
> let (num1, next1) =3D (counter 5)
> (num2, next2) =3D (next1 100)
> (num3, next3) =3D (next2 50) in
> Will have the numbers [5, 105, 155].
What do you mean by "determine"?
You can write =
sequence =3D iterate step_counter 0
if the interval between successive numbers is determined by
the current number, or
sequence =3D map f [1..]
if it's determined by the index in the sequence.
sequence =3D map snd $ iterate step_counter (0,-7)
step_counter (a,b) =3D (a+1, f a b) =
if it depends on both.
J=F3n Fairbairn Jon.Fairbairn@cl.cam.ac.u=
31 Chalmers Road firstname.lastname@example.org
Cambridge CB1 3SZ +44 1223 570179 (after 14:00 only, please!)