diff:edit-length implements the algorithm:
The values returned by diff:edit-length can be used to gauge
the degree of match between two sequences.
diff:edits and diff:longest-common-subsequence combine
the algorithm with the divide-and-conquer method outlined in:
If the items being sequenced are text lines, then the computed edit-list is equivalent to the output of the diff utility program. If the items being sequenced are words, then it is like the lesser known spiff program.
array1 and array2 are one-dimensional arrays.
The non-negative integer p-lim, if provided, is maximum number of deletions of the shorter sequence to allow.
diff:longest-common-subsequencewill return#fif more deletions would be necessary.
diff:longest-common-subsequencereturns a one-dimensional array of length(quotient (- (+ len1 len2) (diff:edit-lengtharray1 array2)) 2)holding the longest sequence common to both arrays.
array1 and array2 are one-dimensional arrays.
The non-negative integer p-lim, if provided, is maximum number of deletions of the shorter sequence to allow.
diff:editswill return#fif more deletions would be necessary.
diff:editsreturns a vector of length(diff:edit-lengtharray1 array2)composed of a shortest sequence of edits transformaing array1 to array2.Each edit is an integer:
- k > 0
- Inserts
(array-refarray1(+ -1j))into the sequence.- k < 0
- Deletes
(array-refarray2(- -1k))from the sequence.
array1 and array2 are one-dimensional arrays.
The non-negative integer p-lim, if provided, is maximum number of deletions of the shorter sequence to allow.
diff:edit-lengthwill return#fif more deletions would be necessary.
diff:edit-lengthreturns the length of the shortest sequence of edits transformaing array1 to array2.
(diff:longest-common-subsequence "fghiejcklm" "fgehijkpqrlm")
⇒ "fghijklm"
(diff:edit-length "fghiejcklm" "fgehijkpqrlm")
⇒ 6
(diff:edits "fghiejcklm" "fgehijkpqrlm")
⇒ #A:fixZ32b(3 -5 -7 8 9 10)
; e c h p q r