[cl-unification-devel] copy-env

norman werner norman.werner at web.de
Sun Dec 4 10:03:17 UTC 2005


Hello

While writing  a library with prolog like capabilities on top of cl-unification and a home brewn nondeterministic library
I need a way to copy environments.

There is a (internal) function copy-env in cl-unification. So I exported it.
The problem is that this function returns a new environment which actually still shares
objects with its original argument.

Is this intentional? 
If not I propose the following (code will certainly contain bug, because i write it from memory only)

(defun copy-env (e)
  (make-environment :frames (mapcar #'copy-frame (frames e))))

(defun copy-frame (f)
  (make-frame :bindings (mapcar #'copy-binding (binding f))))

(defun copy-binding (b)
   (mapcar #'(lambda (cell) (cons (car cell)
                                                    (cdr cell))) b))



Norman
______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193




More information about the cl-unification-devel mailing list