The functions:
> f [] w = (w,0)
> f (x:xs) w = (nextw, steps+1)
> where
> (nextw, steps) = f xs (g x w)
>
>
> f2 [] k w = (w,k)
> f2 (x:xs) k w = f2 xs (k+1) (g x w)
>
>
> f3 [] w = w
> f3 (x:xs) w = f3 xs (g x w)
> O
Hi all, got some questions on recursive functions.
I got a simple recursive function (f3)
In *some* situations I'll want to know how many recursive calls did it make.
I came up with two simple implementations to do that (f1) and (f2)
f [] w = (w,0)
Hi all, got some questions on recursive functions.
I got a simple recursive function (f3)
In *some* situations I'll want to know how many recursive calls did it make.
I came up with two simple implementations to do that (f1) and (f2)
f [] w = (w,0)
f (x:xs) w = (nextw, steps+1)
where