From cb6d78698b147e41f5c7c1c888644dcd9cf866e7 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Wed, 8 Dec 2010 16:55:02 -0500 Subject: [PATCH] Count pairs as having size 1, not 0, in minimizing edit distance. --- collects/tests/unstable/sexp-diff.rkt | 6 +++++- collects/unstable/sexp-diff.rkt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/collects/tests/unstable/sexp-diff.rkt b/collects/tests/unstable/sexp-diff.rkt index 34764b42a9..13821070b2 100644 --- a/collects/tests/unstable/sexp-diff.rkt +++ b/collects/tests/unstable/sexp-diff.rkt @@ -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)) + ) diff --git a/collects/unstable/sexp-diff.rkt b/collects/unstable/sexp-diff.rkt index bc05743ff9..46ffc90d7d 100644 --- a/collects/unstable/sexp-diff.rkt +++ b/collects/unstable/sexp-diff.rkt @@ -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))