lojix/logic/src/main/com/thesett/aima/logic/fol/Functor.java
public boolean structuralEquals(Term term)
    {
        Term comparator = term.getValue();

        if (this == comparator)
        {
            return true;
        }

        if ((comparator == null) || !(getClass().isAssignableFrom(comparator.getClass())))
        {
            return false;
        }

        Functor functor = (Functor) comparator;

        if ((arity != functor.arity) || (name != functor.name))
        {
            return false;
        }

        // Check the arguments of this functor and the comparator for structural equality.
        boolean passedArgCheck = true;

        if (arguments != null)
        {
            for (int i = 0; i < arguments.length; i++)
            {
                Term leftArg = arguments[i];
                Term rightArg = functor.arguments[i];

                if (!leftArg.structuralEquals(rightArg))
                {
                    passedArgCheck = false;

                    break;
                }
            }
        }

        return passedArgCheck;
    }
public boolean structuralEquals(Term term)
    {
        Term comparator = term.getValue();

        if (this == comparator)
        {
            return true;
        }

        if ((comparator == null) || !(getClass().isAssignableFrom(comparator.getClass())))
        {
            return false;
        }

        Functor functor = (Functor) comparator;

        if ((arity != functor.arity) || (name != functor.name))
        {
            return false;
        }

        // Check the arguments of this functor and the comparator for structural equality.
        boolean passedArgCheck = true;

        if (arguments != null)
        {
            for (int i = 0; i < arguments.length; i++)
            {
                Term leftArg = arguments[i];
                Term rightArg = functor.arguments[i];

                if (!leftArg.structuralEquals(rightArg))
                {
                    passedArgCheck = false;

                    break;
                }
            }
        }

        return passedArgCheck;
    }
Compares this term for structural equality with another. Two terms are structurally equal if they are the same
functor with the same arguments, or are the same unbound variable, or the bound values of the left or right
variable operands are structurally equal. Structural equality is a stronger equality than unification and unlike
unification it does not produce any variable bindings. Two unified terms will always be structurally equal.

@param  term The term to compare with this one for structural equality.

@return <tt>true</tt> if the two terms are structurally eqaul, <tt>false</tt> otherwise.