逐步运行功能来模拟图灵机?

时间:2017-05-03 18:34:22

标签: python computation-theory turing-machines

只是一个随机问题 - 有没有办法逐步运行Python函数?我希望能够模拟像鸠尾榫一样的东西 - 对于每个输入,我可以在那里运行该函数的一步,这样它就可以输出所有的返回语句,而不会陷入无限循环。我希望它是这样的:

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

有没有办法做到这一点,还是我只是疯了?有点像pdb,但我不希望它是调试。

0 个答案:

没有答案