A function a fund quite useful, so I thought I'd pass it on.
def mkfun(expr):
""" Creates a lambda with arguments which are the alphabetically
ordered free symbols.
E.g.
f1 = mkfun(x**2)
print(f1(3))
f2 = mkfun(x**2 + y**2)
print(f2(3,4))
f3 = mkfun(x**2 + y**2 + z**2)
print(f3(3,4,5))
"""
free = list(ordered(expr.free_symbols))
return lambda *x: expr.subs(zip(free,x))
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/3f838d49-d9cb-4e5e-a042-6496fec895a8n%40googlegroups.com.