Author: hannes
Date: Tue May 30 22:09:21 2006
New Revision: 10760
Modified:
trunk/fundev/sources/lib/collection-extensions/sequence-diff.dylan
Log:
Job: fd
fix diff algorithm (didn't work if only added/removed something at the end of
the sequence)
sequence-diff(#("foo", "bar", "boo"), #("foo", "bar", "boo", "baz"))
-> should be ported to src/common/collection-extensions for gwydion...
Modified: trunk/fundev/sources/lib/collection-extensions/sequence-diff.dylan
==============================================================================
--- trunk/fundev/sources/lib/collection-extensions/sequence-diff.dylan
(original)
+++ trunk/fundev/sources/lib/collection-extensions/sequence-diff.dylan Tue May
30 22:09:21 2006
@@ -84,7 +84,16 @@
if (lower > upper) // sequences are identical
return(#());
end if;
-
+ if (lower = 1 & upper = 1)
+ return(list(make(<insert-entry>,
+ source-index: row,
+ dest-index: row,
+ count: seq2.size - row)));
+ elseif (lower = -1 & upper = -1)
+ return(list(make(<delete-entry>,
+ dest-index: row,
+ count: seq1.size - row)))
+ end;
// For each diagonal k, last-distance[k] is the last row that
// contains the desired distance.
//
--
Gd-chatter mailing list
Gd-chatter@xxxxxxxxxxxxxxxx
https://www.gwydiondylan.org/mailman/listinfo/gd-chatter
|