ddiff

This module provides a diff() function.

The function takes two slicable forward ranges of < and == comparable objects (e.g., two slices of strings, two strings, two slices of ints, two slices of "items") and diffs them using a slightly simplified version of the Python difflib's sequence matcher algorithm. The function returns a (possibly empty) slice of Diff structs, each with a tag (equal, insert, delete, replace) and the two relevant subslices.

See tests.d for some examples including Test #17, #18 and #19.

Members

Enums

EqualSpan
enum EqualSpan

Used to tell the diff() function whether to include Diff structs in its output slice that have all possible tags, including the Equal tag (Keep), or only difference tags, Insert, Delete, Replace (Drop).

Tag
enum Tag

What kind of difference the Diff struct represents.

Functions

diff
auto diff(R a, R b, EqualSpan equalSpan = EqualSpan.Drop)

Iterates two slices and diffs them.

Structs

Diff
struct Diff(E)

A difference with a tag to specify what the difference is and the two relevant subslices.

Meta

Authors

Mark Summerfield, mark@qtrac.eu

License

Apache 2.0