Skip to content

Commit

Permalink
docstrings, comments, type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
algal committed Sep 30, 2011
1 parent 8540515 commit 7b1b230
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions diff.lisp
Expand Up @@ -81,16 +81,23 @@
,@body))))

(defun intern-files (&rest files)
"Returns values of an interner and list of interned-files"
"Returns values of an interner and list interned-files.
The interner contains the mapping from codes to objects (strings).
Each interned-file is a vector of the intern codes for the file's lines"
(let ((interner (make-interner))
(interned-files nil))
;; for each file..
(dolist (file files
(values interner (nreverse interned-files)))
(let ((interned-file nil))
(do-file-lines (line file)
;; intern each line of file
(let ((code (intern-string interner line)))
;; collecting the intern codes
(push code interned-file)))
(push (coerce (nreverse interned-file) 'simple-vector) interned-files)))))
;; save the list of codes as a correctly-ordered vector
(push (coerce (nreverse interned-file) 'simple-vector)
interned-files)))))

;;; Computing longest common subsequences between two sequences whose
;;; elements compare equal via EQL. The algorithm used here is based
Expand All @@ -111,6 +118,7 @@
(snake-length snake))))

(defun snake (lcs original modified k y)
(declare (type simple-vector original modified))
(let* ((x (- y k))
(y y)
(x-start x)
Expand Down Expand Up @@ -174,6 +182,10 @@
(do-snake delta))))))

(defun compute-lcs (original modified)
"Computes longest common sequence.
Takes ORIGINAL and MODIFIED, two vectors of intern codes. Compute LCS
using algorithm from _An O(NP) Sequence Comparison Algorithm_ by Sun
Wu, Udi Manber, and Gene Meyers"
(let* ((original-length (length original))
(modified-length (length modified))
(modified-longer-p (> modified-length original-length))
Expand Down

0 comments on commit 7b1b230

Please sign in to comment.