A D implementation of Python's difflib sequence matcher
To use this package, run the following command in your project's root directory:
A D implementation of Python difflib'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
For example, this code:
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"]
Diff.toString() method is really just for testing. Each
struct has a
Tag indicating the kind of difference (
Replace) and (in
b), the relevant subslices of the
two input ranges.
ddiff is free open source software (FOSS) licensed under the Apache License, Version 2.0.
- Registered by Mark
- 0.1.0 released 6 months ago
- Copyright © 2020 Mark Summerfield. All rights reserved.