Exemple #1
0
 def discard(self, Other: PyValue) -> PySet:
     Other_EoT = Other.unification_chain_end()
     new_args = [arg for arg in self.args if arg != Other_EoT]
     new_set = PySet(new_args)
     return new_set
Exemple #2
0
        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):
            # Since E is a Var, must take its unification_chain_end to get something that has a head and tail.
            E_EoC = E.unification_chain_end()
            assert isinstance(E_EoC, LinkedList)
            print(
                f'5b. unify(E, B) => E: {E}, E_EoT.head(): {E_EoC.head( )}, E_EoT.tail(): {E_EoC.tail( )}\n'
            )

    # The empty LinkedList is a LinkedList ith no arguments.
    head = PyValue('head')
    Unclosed_List1 = LinkedList(head, Var())
    print(
        f'6. Unclosed_List1: {Unclosed_List1}, len(Unclosed_List1): {len(Unclosed_List1)}'
    )
    Unclosed_List2 = LinkedList(Var(), Var())
    print(
        f'7. Unclosed_List2: {Unclosed_List2}, len(Unclosed_List2): {len(Unclosed_List2)}'
    )