Land of Lisp function uedges->dot error or can't understand

123 Views Asked by At

http://landoflisp.com/graph-util.lisp

(defun uedges->dot (edges);draw undirected graphs
  (maplist (lambda (lst)
         (mapc (lambda (edge)
                 (unless (assoc (car edge) (cdr lst))
                   (fresh-line)
                   (princ (dot-name (caar lst)))
                   (princ "--")
                   (princ (dot-name (car edge)))
                   (princ "[label=\"")
                   (princ (dot-label (cdr edge)))
                   (princ "\"];")))
               (cdar lst)))
       edges))

I thought this function has some problem, can someone fix it?

1

There are 1 best solutions below

0
On

I solved it by myself. I hope somebody take care, while studying land of lisp p125 uedges-dot function.

(defun uedges->dot (edges);draw undirected graphs
 (maplist (lambda (lst)
     (mapc (lambda (edge)
         (unless (assoc (caar lst)
                        (cdr (assoc (car edge) (cdr lst))));<-----modify 'unless'
           (fresh-line)
           (princ (dot-name (caar lst)))
           (princ "--")
           (princ (dot-name (car edge)))
           (princ "[label=\"")
           (princ (dot-label (cdr edge)))
           (princ "\"];")))
       (cdar lst)))
   edges))