Lisp HUG Maillist Archive

Re: Recursive calls

Oh, sorry. It was defaced version of Paul Graham's text. I've inserted it without checking from
file where original was stored previously. That "DO" was result of  first and unfinished attempt to make iterative version.
 
Here is original:
 
(defun bst-insert (obj bst <)
  (declare (optimize (speed 3)(debug 0)(safety 0)))
  (if (null bst)
     (make-node :elt obj))
        (let ((elt (node-elt bst)))
          (if (eql obj elt)
          bst
          (if (funcall < obj elt)
              (make-node
               :elt elt
               :l (bst-insert obj (node-l bst) <)
               :r (node-r bst))
              (make-node
               :elt elt
               :r (bst-insert obj (node-r bst) <)
               :l (node-l bst))))))
 
Of course It's again not tail recursive, but it is more suitable to change to. 
 
Thank you for replies.
Lisper
 
 
 
 
 
 
 
Updated at: 2020-12-10 08:54 UTC