【问题标题】:Lisp: EVAL/APPLY: Too few arguments (1 instead of at least 2) given to INSERTBST errorLisp:EVAL/APPLY:给 INSERTBST 错误的参数太少(1 个而不是至少 2 个)
【发布时间】:2021-03-13 16:29:08
【问题描述】:

有谁知道为什么我收到此代码的EVAL/APPLY: Too few arguments (1 instead of at least 2) given to INSERTBST 错误,谢谢。

 (defun insertbst (E tree)
        (cond ((null tree) (list E nil nil))
            (( = E (car tree)) tree)
            (( < E (car tree))
             (list (car tree) (insertbst E (cadr tree))
                   (caddr tree)))
            ( t (list (car tree) (cadr tree) (insertbst E (caddr tree))))))
    
    (print(insertbst'(8 (3 (1 () ()) (6 (4 () ())( 7 () ()))) (10 (()) (14 (13) ())))))

【问题讨论】:

  • 因为您在调用 INSERTBST 函数时提供的参数太少(1 而不是 2)。

标签: lisp common-lisp


【解决方案1】:

你应该用数字和树来调用它。顺便说一句,你树中的一些节点没有两个后代,所以我更正了:

(insertbst 15 '(8 (3 (1 () ()) 
                     (6 (4 () ())
                        ( 7 () ())))
                  (10 () 
                      (14 (13 () ())
                          ()))))

=> (8 (3 (1 NIL NIL) (6 (4 NIL NIL) (7 NIL NIL))) (10 NIL (14 (13 NIL NIL) (15 NIL NIL))))

【讨论】:

    猜你喜欢
    • 2012-10-08
    • 2016-02-28
    • 2014-09-20
    • 2011-12-25
    • 1970-01-01
    • 1970-01-01
    • 2017-12-29
    相关资源
    最近更新 更多