今日、以下のコードをschemeで書きましたが、評価が間違っています。私がプログラミングが苦手だとは言わないでください。これが古典的な再帰問題であることは理解していますが、問題が発生しています。
(define (towers-of-hanoi n source temp dest)
(if (= n 1)
(begin (display "Move the disk from ")
(display source)
(display " to " )
(display dest)
(newline))
(begin (towers-of-hanoi (- n 1) source temp dest)
(display "Move the disk from ")
(display source)
(display " to ")
(display dest)
(newline)
(towers-of-hanoi(- n 1) temp source dest))))
コードが機能することを期待していましたが、デバッグするとさらに混乱してしまいます。誰でも私を助けることができますか?