def __add__(self, Other: Union[PySequence, Var]) -> PySequence: Other_EoT = Other.unification_chain_end() # If not, can't append. assert isinstance(Other_EoT, PySequence) Result = Var() for _ in append(self, Other_EoT, Result): Result_EoT = Result.unification_chain_end() # To make the PyCharm type checker happy. assert isinstance(Result_EoT, PySequence) return Result_EoT
""" print( f'\n?- LinkedList([Var()]).is_instantiated(): {LinkedList([Var( )]).is_instantiated( )}' ) A = LinkedList([1, 2, 3]) B_Head = Var() B_Tail = Var() B = LinkedList(B_Head, B_Tail) print(f'1. A: {A}, B: {B}') for _ in unify(A, B): print(f'2. A: {A}, B: {B}') B_Tail_TrailEnd = B_Tail.unification_chain_end() C = LinkedList([0, *B_Tail_TrailEnd.get_py_value()]) print(f'3. C: {C}') D2 = Var() D3 = Var() D = LinkedList([D3, D2, D3]) print(f'4a. B: {B}, D: {D}') for _ in unify(D.tail(), B.tail()): print(f'4b. unify(D.tail(), B.tail() => B: {B}, D: {D}') for _ in unify(D.head(), B): print(f'4c. unify(D.head(), B) => B: {B}, D: {D}') E = Var() print(f'5a. B: {B}, E: {E}') for _ in unify(E, B):