简体   繁体   English

Lisp:EVAL/APPLY:太少 arguments(1 而不是至少 2)给 INSERTBST 错误

[英]Lisp: EVAL/APPLY: Too few arguments (1 instead of at least 2) given to INSERTBST error

does anyone knows why i'm getting EVAL/APPLY: Too few arguments (1 instead of at least 2) given to INSERTBST error for this code, thank you.有谁知道为什么我得到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) ())))))

You should call it with number and tree.你应该用数字和树来调用它。 By the way, some nodes in your tree don't have two descendants, so I corrected that:顺便说一句,你的树中的一些节点没有两个后代,所以我更正了:

(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)))) => (8 (3 (1 NIL NIL) (6 (4 NIL NIL) (7 NIL NIL))) (10 NIL (14 (13 NIL NIL) (15 NIL NIL))))

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

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