Count pairs as having size 1, not 0, in minimizing edit distance.

This commit is contained in:
Sam Tobin-Hochstadt 2010-12-08 16:55:02 -05:00
parent 73dbf42e0e
commit cb6d78698b
2 changed files with 6 additions and 2 deletions

View File

@ -19,4 +19,8 @@
(sexp-diff '(defun f (x) (+ (* x 2) 4 4 1))
'(defun f (x) (- (* x 2) 5 5 3 1)))
=> '((defun f (x) #:new (- (* x 2) 5 5 3 1) #:old (+ (* x 2) 4 4 1))))
=> '((defun f (x) (#:new - #:old + (* x 2) #:new 5 #:new 5 #:new 3 #:old 4 #:old 4 1)))
(sexp-diff (list 1 (list 2) 3) (list 1 (list 4) 3))
=> '((1 (#:new 4 #:old 2) 3))
)

View File

@ -50,7 +50,7 @@
;; Computes the number of atoms contained in TREE.
(define (tree-size tree)
(if (pair? tree)
(apply + (map tree-size tree))
(apply + 1 (map tree-size tree))
1))