Module Diff2.Make
Functor building an implementation of the diff structure given a sequence type.
Parameters
Signature
type t
= M.t
The type of input sequence.
type elem
= M.elem
The type of the elements of result / input sequence.
val lcs : ?equal:(elem -> elem -> bool) -> t -> t -> elem common list
lcs ~equal seq1 seq2
computes the LCS (longest common sequence) ofseq1
andseq2
. Elements ofseq1
andseq2
are compared withequal
.equal
defaults toPervasives.(=)
.Elements of lcs are
`Common (pos1, pos2, e)
wheree
is an element,pos1
is a position inseq1
, andpos2
is a position inseq2
.
val diff : ?equal:(elem -> elem -> bool) -> t -> t -> elem edit list
diff ~equal seq1 seq2
computes the diff ofseq1
andseq2
. Elements ofseq1
andseq2
are compared withequal
.Elements only in
seq1
are represented as`Removed (pos, e)
wheree
is an element, andpos
is a position inseq1
; those only inseq2
are represented as`Added (pos, e)
wheree
is an element, andpos
is a position inseq2
; those common inseq1
andseq2
are represented as`Common (pos1, pos2, e)
wheree
is an element,pos1
is a position inseq1
, andpos2
is a position inseq2
.