Am trying to write a recurssive function to do something, but at each step I'd like to know the current depth / index in the tree. So how can I achieve this without use of an index parameter in the function signature?
Something like:
rec_fn n = do print index
do_something n
if n > 0
then rec_fn (n-1)
else print "end"
so how do I obtain index, without doing something like:
rec_fn n i = do print i
do_something n
if n > 0
then rec_fn (n-1) (i+1)
else print "end"