Summary
###########################################################################
File: dif.icn
Subject: Procedure to check for differences
Author: Robert J. Alexander
Date: August 14, 1996
###########################################################################
This file is in the public domain.
###########################################################################
dif(stream, compare, eof, group)
generates a sequence of differences between an arbitrary
number of input streams. Each result is returned as a list
of diff_recs, one for each input stream, with each diff_rec
containing a list of items that differ and their position
in the input stream.
The diff_rec type is declared as:
record diff_rec(pos,diffs)
dif() fails if there are no differences, i.e. it produces an empty
result sequence.
###########################################################################
For example, if two input streams are:
a b c d e f g h
a b d e f i j
the output sequence would be:
[diff_rec(3,[c]),diff_rec(3,[])]
[diff_rec(7,[g,h]),diff_rec(6,[i,j])
The arguments to dif(stream,compare,eof,group) are:
stream A list of data objects that represent input streams
from which dif will extract its input "records".
The elements can be of several different types which
result in different actions, as follows:
Type Action
=========== =============================
file file is "read" to get records
co-expression co-expression is activated to
get records
list records are "gotten" (get()) from
the list
diff_proc a record type defined in "dif" to
allow a procedure (or procedures)
suppled by dif's caller to be called
to get records. Diff_proc has two
fields, the procedure to call and the
argument to call it with. Its
definition looks like this:
record diff_proc(proc,arg)
Optional arguments:
compare Item comparison procedure -- succeeds if
"equal", otherwise fails (default is the
identity "===" comparison). The comparison
must allow for the fact that the eof object
(see next) might be an argument, and a pair of
eofs must compare equal.
eof An object that is distinguishable from other
objects in the stream. Default is &null.
group A procedure that is called with the current number
of unmatched items as its argument. It must
return the number of matching items required
for file synchronization to occur. Default is
the formula Trunc((2.0 * Log(M)) + 2.0) where
M is the number of unmatched items.
###########################################################################
Procedures:
dif, diffread, groupfactor
Records:
diff_file, diff_proc, diff_rec
This file is part of the (main) package.
Source code.
dif(stream, compare, eof, group)
diffread(f)
diffread() -- Read a line from an input stream.
groupfactor(m)
groupfactor() -- Determine how many like lines we need to close
off a group of differences. This is the default routine -- the
caller may provide his own.
Compute: Trunc((2.0 * Log(m)) + 2.0)
diff_file(stream, queue)
diff_proc(proc, arg)
diff_rec(pos, diffs)
This page produced by UniDoc on 2021/04/15 @ 23:59:54.