Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Diff algorithm in Erlang
branch: master
Failed to load latest commit information.
example Initial commit
src Add tdiff_benchmark.erl
test Initial commit
.gitignore Ignore ebin/
COPYING.LIB Initial commit Correct spelling mistake
rebar.config Initial commit

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:

Something went wrong with that request. Please try again.