What is the best way to detect order of matching functions in recursion?

Hi! I’m newbie.
My questions is like the subject: Let say I have a recursion task which I’ll use a bunch of recursion functions to handle.

def do_something(_), do:  do_something(_)
def do_something(_) when *some_condition*, do:  do_something(_)
.........
def do_something(_, _, _) when *more_conditions*, do: do_something(_)

I wonder whether Elixir support debug methods to check the sequence my code (which specific input) will be executed. I mean Can it show my recursion task jumped in do_something functions with order like: 4 → 5 → 3 → 7 → 1 ?
The easy way I could think of as a newbie is put IO.puts in each do_something function which might not be efficient way…
Sorry If my descriptionis not clear. Thanks for reading.

outputting something via puts or inspect would be the simplest. You could also temporarily raise an exception on one call at a time. I haven’t used it but there is a Dbg package on hex that might be useful for this kind of tracing.

3 Likes

Thank you!

I haven’t used it but there is a Dbg package on hex that might be useful for this kind of tracing.

I’ll give it a try :smiley:

You can use the debugger. There is also a trace functionnality I believe.

2 Likes

Thanks for reminding me!
That’s exactly what I’m looking for :smiley:

1 Like