Lisp函数的功能uedges->点错误或无法理解

时间:2012-08-13 17:03:31

标签: common-lisp land-of-lisp

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

我认为这个功能有问题,有人可以解决吗?

1 个答案:

答案 0 :(得分:1)

我自己解决了。我希望有人在研究lisp p125 uedges-dot功能的土地时要小心。

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