@Override public List copy(Map<Variable, Variable> sharedVariables) { if (immutable) { return this; } else { Term newHead = head.copy(sharedVariables); Term newTail = tail.copy(sharedVariables); if (newHead == head && newTail == tail) { return this; } else { return new List(newHead, newTail, newHead.isImmutable() && newTail.isImmutable()); } } }
@Override public List getTerm() { if (immutable) { return this; } else { Term newHead = head.getTerm(); Term newTail = tail.getTerm(); if (newHead == head && newTail == tail) { return this; } else { return new List(newHead, newTail, newHead.isImmutable() && newTail.isImmutable()); } } }