Exemple #1
0
def test_function():
    f = Function('f')
    x = Symbol('x')
    e = f(x)
    m = Match(e)
    assert m(f) == True
    assert m.type(FunctionClass) == True
    def __call__(self,e):
        v = AutoVar()
        m = Match(e)

        #if m(self.old):
        if m.type(FunctionClass):
            if type(e) == self.old:
                arg = self.new.lhs.args[0] 
                return self.new.rhs.subs(arg, e.args[0])

        if (len(e.args)) == 0:
            return e

        arg = e.args
        new_args = []
        for a in arg:
            other = self(a)
            new_args.append(other)
        r = e.func(*new_args)
        return r