Try :
In [1]: from sympy import Lambda In [2]: help(Lambda) HTH, Le lundi 18 avril 2022 à 12:12:31 UTC+2, [email protected] a écrit : > Sorry about the spelling. I meant to write "A function which I find quite > useful." > > def mkfun(expr): > free = list(ordered(expr.free_symbols)) > return lambda *x: expr.subs(zip(free,x)) > > :o) > > On Sunday, April 17, 2022 at 10:33:37 AM UTC+1 Andre Bolle wrote: > >> 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/43b84a0b-6b79-45d4-b89d-575e0ce44c1an%40googlegroups.com.
