On Feb 27, 2:15 am, justinc...@[EMAIL PROTECTED]
wrote:
> Hi, I'm new to lisp and trying to get a feel for things in CL. To that
> end, I'm trying to write a binary tree, but I can't figure out how to
> do it the way I'd like. Given nodes in the form of (key left-child
> right-child . data), I'd prefer to write something like
>
> <code>
> (defun insert (key data &optional (node *root*))
> (progn
> (if (null *root*)
> (setf *root* (make-node key data)))
> (destructuring-bind (k l r . d) node
> (if (funcall test k key)
> (setf node (make-node key data l r))
> (insert key data (if (funcall cmp k key)
> l
> r))))))
> </code>
>
> for the insert function, but obviously this isn't working. As you can
> see, in two places I'm trying to set the <i>place</i> of a variable
> I'm passing into the function, but all I'm really doing is clobbering
> the version in the local scope.
>
> I guess what I'm kind of trying to do is a bit like passing around
> handles (pointers to pointers) in c. Is there some nice way to do
> something like this in CL?
Hi,
I'm new to Lisp too, but here is what a google search on
'binary tree lisp'
yields:
http://www.cs.sfu.ca/CC/310/pwfong/Lisp/3/tutorial3.html
It seems like it is not so trivial.
Good Luck


|