smpl.wrap.get_lambda

smpl.wrap.get_lambda(expr, xvar)[source]

Returns a lambda of given str/function/lambda expression with __doc__ set to the latex expression. xvar is moved to the front.

Examples

>>> l = get_lambda(lambda a,b,c,x : (a+b+c)*x,'x')
>>> l(4,1,1,1)
12
>>> l = get_lambda("(a+b+c)*x",'x')
>>> l(4,1,1,1)
12
>>> def fun(a,b,x,c):
...     return (a+b+c)*x
>>> l = get_lambda(fun,'x')
>>> l(4,1,1,1)
12