/** * Performs a strict comparison of this list to the specified term. * * @param t1 the term to compare this list against * @return {@code true} if the given term represents a {@link TermType#LIST} with a head and tail * strictly equal to the corresponding head and tail of this List object. */ @Override public boolean strictEquality(Term t1) { // used to be implemented using recursion but caused stack overflow problems with long lists Term t2 = this; do { boolean equal = t1.getType() == TermType.LIST && t1.getArgument(0).strictEquality(t2.getArgument(0)); if (equal == false) { return false; } t1 = t1.getArgument(1); t2 = t2.getArgument(1); } while (t2.getType() == TermType.LIST); return t1.strictEquality(t2); }