From 9f60184ba78992422342b614d187f53880921de3 Mon Sep 17 00:00:00 2001 From: Cas Cremers Date: Tue, 26 Apr 2011 11:49:40 +0200 Subject: [PATCH] Add isTermlistSetEqual code to compare sets that are encoded as lists. --- src/termlist.c | 17 +++++++++++++++++ src/termlist.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/termlist.c b/src/termlist.c index 430a109..1e4bcd5 100644 --- a/src/termlist.c +++ b/src/termlist.c @@ -762,6 +762,23 @@ termlistContained (const Termlist tlbig, Termlist tlsmall) return 1; } +//! Check whether the element sets corresponding to two termlist are equal +/** + * Currently this is a classical two-way containment test, but probably it can be done smarter. + */ +int +isTermlistSetEqual (const Termlist tl1, const Termlist tl2) +{ + if (termlistContained (tl1, tl2)) + { + if (termlistContained (tl2, tl1)) + { + return true; + } + } + return false; +} + //! Yield the result of f(x) /** * This function interpretes two termlists as the domain and range of a function, diff --git a/src/termlist.h b/src/termlist.h index 8507540..bdacb50 100644 --- a/src/termlist.h +++ b/src/termlist.h @@ -71,6 +71,7 @@ Term termLocal (const Term t, Termlist fromlist, Termlist tolist); Termlist termlistLocal (Termlist tl, const Termlist fromlist, const Termlist tolist); int termlistContained (const Termlist tlbig, Termlist tlsmall); +int isTermlistSetEqual (const Termlist tl1, const Termlist tl2); Term termFunction (Termlist fromlist, Termlist tolist, Term tx); Termlist termlistForward (Termlist tl); int termlistOrder (Termlist tl1, Termlist tl2);