"Charlie Taylor" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> I find that I use lambda functions mainly for callbacks to things like
> integration or root finding routines as follows.
>
> flow = integrate(lambda x: 2.0*pi * d(x)* v(x) * sin(a(x)),xBeg, xEnd)
>
> root = findRoot(xBeg, xEnd,
>       lambda x: y2+ lp*(x-x2) -wallFunc( x )[0], tolerance=1.0E-15)

To each there own is my philosophy.  However, with multiple arguments, I 
might prefer

def f(x): return 2.0*pi * d(x)* v(x) * sin(a(x))
flow = integrate(f, xBeg, xEnd)

def g(x): return y2+ lp*(x-x2) -wallFunc( x )[0]
root = findRoot(xBeg, xEnd, g, tolerance=1.0E-15)

even if I might use lambda initially.  (And the above is in no way a 
'mess'.)

In any case, as soon as one wants to do even two things with a function --  
plot and integrate, or integrate with two methods and compare, or ditto 
with findRoot, or calculate g(root) after findRoot, one will want a 
separate def statement.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to