繁体   English   中英

计划中的问题

[英]question in scheme

Scheme的下一个程序解决了Hanoy塔的问题是什么?

(define tower_of_hanoi
  (lambda (move discs from to using)
    (if (> discs 0)
        ((tower_of_hanoi move (- discs 1) from using to)
        (tower_of_hanoi move (- discs 1) using to from)))))

(procedure application: expected procedure, given: #void; arguments were: #void)

谢谢大家

在您的代码中,您正在()中调用了两个函数。 使用该符号时,您的符号必须是一个函数/过程。 所以你得到了错误。

检查下面的代码。 我改成了(and

(define tower_of_hanoi
  (lambda (move discs from to using)
    (if (> discs 0)
        (and (tower_of_hanoi move (- discs 1) from using to)
             (display move)(display " from ")(display from) (display " to ")(display to) (display "\n")
             (tower_of_hanoi move (- discs 1) using to from)))))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM