ddiff 0.1.7

A D implementation of Python's difflib sequence matcher


To use this package, run the following command in your project's root directory:

ddiff

A D diff library that implements the Python difflib module's sequence matcher.

ddiff is a library for finding the differences between two sequences.

The sequences can be of lines, strings (e.g., words), characters, bytes, or of any custom “item” type so long as it implements == and <.

Examples

For example, this code:

import qtrac.ddiff: diff, EqualSpan;

auto diffs = diff(
    "the quick brown fox jumped over the lazy dogs".split!isWhite,
    "the quick red fox jumped over the very busy dogs".split!isWhite,
    EqualSpan.Keep);
foreach (diff; diffs)
    writeln(diff.toString());

produces this output:

= ["the", "quick"]
< ["brown"] |> ["red"]
= ["fox", "jumped", "over", "the"]
< ["lazy"] |> ["very", "busy"]
= ["dogs"]

By default the third argument is EqualSpan.Drop, in which case the output from the above would be:

< ["brown"] |> ["red"]
< ["lazy"] |> ["very", "busy"]

The Diff.toString() method is really just for testing. Each Diff struct has a Tag indicating the kind of difference (Equal, Insert, Delete, Replace) and (in a and b), the relevant subslices of the two input ranges.

See also src/tests.d, especially the tests near the end.

License

ddiff is free open source software (FOSS) licensed under the Apache License, Version 2.0.

Authors:
  • Mark Summerfield
Dependencies:
none
Versions:
0.1.10 2020-Mar-13
0.1.9 2020-Mar-08
0.1.8 2020-Mar-08
0.1.7 2020-Feb-27
0.1.6 2020-Feb-26
Show all 12 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 2 downloads total

Score:
0.5
Short URL:
ddiff.dub.pm