Sorry, I didn't realize that. Here's the code.

---
def symbolic_function(variables, *args, **kwds):
    def result(f):
        def evalf_func(self,x,parent=None):
            if parent == None:
                return f(x)
            else:
                return parent(f(x))
        return function(f.__name__, variables, evalf_func=evalf_func, 
*args, **kwds).operator()
        
    return result

@symbolic_function(x)
def steps(x):
    if x < 0:
        return -x
    elif x < 3:
        return x
    else:
        return 3

steps(5)

n(steps(5))

plot(steps(x),(x,-3,6))

-- 
-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org



Reply via email to