Just a random question - is there any way to run a Python function step by step? I want to be able to simulate things like dovetailing - where for each input I can run one step of the function at the time, so that it outputs all the return statements, without being stuck in an infinite loop. I would want it to be something like this:
f = (collatz conjecture function)
processes = []
i = 0
while True:
processes.append(f(i)) # Add the function on that input but dont run it
for p in processes:
(run p for 1 step. If it halts, print its input)
i+=1
Is there any way to do this, or am I just crazy? Kind of like pdb, but I dont want it to be debugging.