|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
text.diff- Calculate difference of text streams
This module calculates the difference of two text streams or strings,
util.lcs (See section
util.lcs - The longest common subsequence).
Generates an "edit list" from text sources src-a and src-b.
Each of text sources, src-a and src-b, can be either an input
port or a string. If it is a string, it is converted to a string input
port internally. Then, the text streams from both sources are converted
to sequences by calling reader repeatedly on them; the default
of reader is
read-line, and those sequences are
lcs-edit-list to calculate the edit list.
The equality function eq-fn is also passed to
An edit list is a set of commands that turn the text sequence
src-a to the one from
See the description of
the detailed explanation of the edit list.
(diff "a\nb\nc\nd\n" "b\ne\nd\nf\n") ⇒ (((- 0 "a")) ((- 2 "c") (+ 1 "e")) ((+ 3 "f")))
A convenience procedure to take the diff of two text sources
and display the result nicely. This procedure calls
to calculate the difference of two text sources. The meanings of
src-a, src-b, reader and eq-fn are the
Writer is a procedure that takes two arguments, the text element
and a type, which is either a symbol
#f. If the text element is only
in src-a, writer is called with the element and
-. If the text element is only in src-b,
it is called with the element and
+. If the text element
is in both sources, it is called with the element and
#f. The default procedure of writer prints
the passed text element to the current output port
in unified-diff-like format:
(diff-report "a\nb\nc\nd\n" "b\ne\nd\nf\n")
- a b - c + e d + f
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]|
This document was generated on July 19, 2014 using texi2html 1.82.