On Wed, 05 Oct 2011 at 12:40AM -0500, Jason Grout wrote:
> On 10/4/11 11:14 PM, Mike Hansen wrote:
> >On Tue, Oct 4, 2011 at 9:09 PM, Dan Drake<[email protected]>  wrote:
> >>It seems unreasonably annoying to plot a bunch of Bessel functions
> >>together. How can I work around this?
> >
> >This is due to the way binding works in list comprehensions.  For a
> >good explanation and workaround, see
> >http://stackoverflow.com/questions/139819/why-results-of-map-and-list-comprehension-are-different
> 
> In particular, this is one way to do it:
> 
> sage: f0, f1 = [lambda x,n=n: bessel_J(n, x) for n in [0,1]]
> sage: f0(0)
> 1.00000000000000

Thanks Mike and Jason. (And Andrzej for the simple workaround I should
have thought of...) The "lambda x,n=n:" looks weird, but the
Stackoverflow page explained it well enough.

Dan

--
---  Dan Drake
-----  http://mathsci.kaist.ac.kr/~drake
-------

Attachment: signature.asc
Description: Digital signature

Reply via email to