简体   繁体   中英

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.

 (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))))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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