Created: 2011-07-09 18:36
Updated: 2018-08-31 23:42
License: other

What is it

A (not very efficient) Erlang implementation of the O(ND) differnence algorithm by Eugene W. Myers see link:


1> tdiff:diff("A cat ate my hat", "A dog ate my shoe").
[{eq,"A "},
 {eq," ate my "},

There is also a debugging engine that generates a series of svg files, for visualizing the progress of the diff algorithm:

2> tdiff_debug:svg_diff("A cat ate my hat", "A dog ate my shoe",

unixprompt% firefox /tmp/diff-trace.svg

The resulting svg works with at least Firefox and Chromium/Google Chrome.

On the todo

The algorithm currently searches only from the beginning to the end. It does not search in both directions, so it ends up searching very many diagonals, most often in vain, so there is room for memory and performance improvements.

Currently, the algorithm only always takes the tail of the list, so it could be possible to use a lazy (memoizing) list.


Much good info about diff, match and patch can found at link:

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more