hey,
i'm trying to figure out a way to create diffs between lists .. diffs
that represent what one would need to do to go from old-list to new-list
wrt. operations (move, append, prepend, insert, remove) .. but maybe
something already exists out there?
i'm doing UI type stuff .. say i'm removing something from a list, then
i insert it back at another place .. the "diff" in this case should
yield a move instead of a remove and an insert
(lisp list <-> "ui container")
the idea is to enable one to use normal lisp list functions on "ui
container widgets" .. i'm thinking something like:
(with-bulk-update-of (some-container)
...)
..and, yeah, before vs. after -- something like that..
..done before in some way?
On Nov 15, 9:01 am, Lars Rune Nøstdal <···········@gmail.com> wrote:
> i'm trying to figure out a way to create diffs between lists .. diffs
> that represent what one would need to do to go from old-list to new-list
> wrt. operations (move, append, prepend, insert, remove) .. but maybe
> something already exists out there?
[...]
> ..and, yeah, before vs. after -- something like that..
>
> ..done before in some way?
This apparently implements Selkow's algorithms:
<http://www.foldr.org/~michaelw/log/programming/lisp/diff-sexp>
My idea was just to lift Levenshtein distance to trees. There are
better ways, however. Dan Ehrenberg did a survey some time ago:
http://factorforge.org/dan/XHTML_diff_survey.pdf
Lars Rune N�stdal <···········@gmail.com> writes:
> hey,
> i'm trying to figure out a way to create diffs between lists .. diffs
> that represent what one would need to do to go from old-list to new-list
> wrt. operations (move, append, prepend, insert, remove) .. but maybe
> something already exists out there?
>
> i'm doing UI type stuff .. say i'm removing something from a list, then
> i insert it back at another place .. the "diff" in this case should
> yield a move instead of a remove and an insert
Are you sure it was a move? Perhaps it was a remove of the elements
before, and an insert of the removed elements after?
(a b c d e f) -> (a d e b c f)
may have been obtained either as:
(a b c d e f) -> (a c d e f) -> (a d e f) -> (a d e c f) -> (a d e b c f)
or:
(a b c d e f) -> (a b c e f) -> (a b c f) -> (a e b c f) -> (a d e b c f)
or a few other ways...
I'll just give you the difference, and let you use them as you want:
C/USER[40]> (COM.INFORMATIMAGO.COMMON-LISP.LIST:TREE-DIFFERENCE
'(a (b nil d) (b c) (d e f) g h)
'(a (b w d) (b c x) (d e y) g h))
(= (= (/= NIL W) = . =) (= = /= NIL (X)) (= = (/= F Y) . =) = = . =)
--
__Pascal Bourguignon__ http://www.informatimago.com/
"I have challenged the entire quality assurance team to a Bat-Leth
contest. They will not concern us again."