equiv.icn: Procedure to compare structures

procedure equiv:           compare values for equivalence

link equiv
February 20, 1996; Ralph E. Griswold
This file is in the public domain.

equiv(s,y)      compare arbitrary structures x and y
____________________________________________________________

   The procedure equiv() tests for the "equivalence" of two values. For types
other than structures, it does the same thing as x1 === x2.  For structures,
the test is for "shape".  For example,

     equiv([],[])

succeeds.

   It handles loops, but does not recognize them as such.  For example,
given

     L1 := []
     L2 := []
     put(L1,L1)
     put(L2,L1)

     equiv(L1,L2)

succeeds.

   The concept of equivalence for tables and sets is not quite right
if their elements are themselves structures.  The problem is that there
is no concept of order for tables and sets, yet it is impractical to
test for equivalence of their elements without imposing an order.  Since
structures sort by "age", there may be a mismatch between equivalent
structures in two tables or sets.

Note:
   The procedures equiv and ldag have a trailing argument that is used on
internal recursive calls; a second argument must not be supplied
by the user.

Source code | Program Library Page | Icon Home Page