A D implementation of Python's difflib sequence matcher
To use this package, run the following command in your project's root directory:
Put the following dependency into your project's dependences section:
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
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"]
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.
src/tests.d, especially the tests near the end.
ddiff is free open source software (FOSS) licensed under the Apache License, Version 2.0.
- Registered by Mark
- 0.1.10 released 2 years ago
- Copyright © 2020 Mark Summerfield. All rights reserved.