"Nick Coghlan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Although if you genuinely prefer a functional programming style,
> I'd go with Terry's answer rather than mine.
The 'iterative' version can also be written recursively, which to most is
functional. For me, the import
Jeff Shannon wrote:
Er, not as far as I can tell the 2.4 feature was what wouldn't work
consistently; the corrected version, using list() and reverse(), doesn't
look like it has anything that'll be a problem in my 2.2 installation,
and probably not in 2.1
What he said :)
Although if yo
"Alan G Isaac" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>I need a clarification of the argument.
> Are the opponents saying that I should not be able to:
If you define 'opponent to lambda' as one who thinks such, then sure ;-).
> def compose(list_of_functions): return reduce(
Alan G Isaac wrote:
So as I understand it, so far the "best" proposal for a
replacement of my function-composition function
uses a (compatibility reducing) Python 2.4 feature
that Nick suggests will end up on "Gotcha" lists.
Er, not as far as I can tell the 2.4 feature was what wouldn't wor
So as I understand it, so far the "best" proposal for a
replacement of my function-composition function
uses a (compatibility reducing) Python 2.4 feature
that Nick suggests will end up on "Gotcha" lists.
Hmmm: lambda is looking pretty good, I'd say.
The readability issue is valid, of course. Bu
Steven Bethard wrote:
Nick Coghlan wrote:
def compose(list_of_functions):
application_order = reversed(list_of_functions)
def composed(x):
for f in application_order:
x = f(x)
return x
return composed
so you either need to call reversed each time in 'composed' or copy the
list
Nick Coghlan wrote:
def compose(list_of_functions):
application_order = reversed(list_of_functions)
def composed(x):
for f in application_order:
x = f(x)
return x
return composed
reversed returns an iterator to the list in reverse order, not a copy of
the list:
>>> lst = range
Alan G Isaac wrote:
I need a clarification of the argument.
Are the opponents saying that I should not be able to:
def compose(list_of_functions): return reduce(lambda f, g: lambda x:
f(g(x)), list_of_functions)
As things stand, I can live with lambda. However, if something can't be said in
a sing
Replying to myself, with a simpler version:
Roel Schroeven wrote:
Alan G Isaac wrote:
def compose(list_of_functions): return reduce(lambda f, g: lambda x:
f(g(x)), list_of_functions)
def compose(list_of_functions):
def compose2(f, g):
def func(x):
return f(g(x))
retu
Alan G Isaac wrote:
I need a clarification of the argument.
Are the opponents saying that I should not be able to:
def compose(list_of_functions): return reduce(lambda f, g: lambda x:
f(g(x)), list_of_functions)
Personally, I think something like this is a place where lambdas are
probably better t
Alan G Isaac wrote:
> Are the opponents saying that I should not be able to:
>
> def compose(list_of_functions): return reduce(lambda f, g: lambda x:
> f(g(x)), list_of_functions)
>
> In a nutshell: why?
I was about to reply, but I couldn't figure out what the piece of code does
in the allotted t
I need a clarification of the argument.
Are the opponents saying that I should not be able to:
def compose(list_of_functions): return reduce(lambda f, g: lambda x:
f(g(x)), list_of_functions)
In a nutshell: why?
And may I see the proposed "better" replacement for function composition.
Thanks,
Al
Simo Melenius wrote:
>> use something short, like "f". hopefully, a single character won't overload
>> your brain.
>
> I've heard some brain can tackle even Java's overly verbose syntax
I find that hard to believe. Are you sure they're not relying on eclipse, or
some
other body part?
> Like s
> I just found it amusing that somenone like Frederik Lundh, who has
> written xml stuff like ElementTree, uses something that reminds of an old
> HTML tag as a sig.
it's a perfectly valid XML end tag. locating the start tag is left as an
exercise...
--
http://mail.python.org/mailman/l
Steve Holden wrote:
Max M wrote:
Isn't it about time you became xml avare, and changed that to:
Yeah, but give the guy a break, we've all made feeble attempts at humor
from time to time.
Hey, what's wrong with a little nørd humor...
I just found it amusing that somenone like Frederik Lundh, who h
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> Simo Melenius wrote:
> > Sure, but mental pollution counts too IMO. What you write and what you
> > read must go through your brain, including dummy variables. And next
> > you start thinking how to "hide" it from your own mind (e.g. naming it
> > "_my
Michael Hoffman wrote:
Max M wrote:
Isn't it about time you became xml avare, and changed that to:
That makes no sense.
Yeah, but give the guy a break, we've all made feeble attempts at humor
from time to time. You realize, I suppose, that it's a reference to the
fact that XHTML uses lower-case
Max M wrote:
Isn't it about time you became xml avare, and changed that to:
That makes no sense.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Walter S. Leipold wrote:
> I think that Charlie's point is that, when you use "def ", you have
> polluting your namespace. The whole program becomes harder to
> understand because you can't ignore anywhere, even if it was only
> ever intended to be used in one place. It's a good point, and reas
The entity Fredrik Lundh wrote:
Isn't it about time you became xml avare, and changed that to:
?
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list
Bengt Richter wrote:
>>Ahem. If you name the function, you can reuse the name (or just forget about
>>it)
>>as soon as you've used the function object.
>>
>>If you don't want to reuse the name because you might want to reuse the
>>function
>>object, you have to name it anyway.
>>
> Are you forg
On Sun, 19 Dec 2004 20:59:43 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>Walter S. Leipold wrote:
>
>> I think that Charlie's point is that, when you use "def ", you have
>> polluting your namespace. The whole program becomes harder to
>> understand because you can't ignore anywhere, eve
On Mon, 20 Dec 2004, Fredrik Lundh wrote:
> Simo Melenius wrote:
>
> >> Ahem. If you name the function, you can reuse the name (or just
> >> forget about it) as soon as you've used the function object.
> >
> > Sure, but mental pollution counts too IMO. What you write and what you
> > read must go t
Simo Melenius wrote:
>> Ahem. If you name the function, you can reuse the name (or just
>> forget about it) as soon as you've used the function object.
>
> Sure, but mental pollution counts too IMO. What you write and what you
> read must go through your brain, including dummy variables. And next
Simo Melenius wrote:
Now, if lambda was more than an expr, dumping "lambda" keyword would
be a convenient idea -- unnecessary keywords can make the language
less clear in some cases. One could do with Python's plain and simple
"def", like this:
filter (def (x): x*2, myseq)
(Disclaimer: Without thin
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> Walter S. Leipold wrote:
> > I think that Charlie's point is that, when you use "def ",
> > you have polluting your namespace. The whole program
> > becomes harder to understand because you can't ignore
> > anywhere, even if it was only ever intended
Walter S. Leipold wrote:
I've used lambda from time to time, but only socially, and I can quit any
time I want...
+1 QOTW
Steve
--
http://mail.python.org/mailman/listinfo/python-list
Walter S. Leipold wrote:
> I think that Charlie's point is that, when you use "def ", you have
> polluting your namespace. The whole program becomes harder to
> understand because you can't ignore anywhere, even if it was only
> ever intended to be used in one place.
Ahem. If you name the fun
Steven Bethard wrote:
> Charlie Taylor wrote:
>>I have tried using named functions instead of using lambda functions,
>>however, I always end up with a convoluted, hard to follow mess.
> ...
> Well, I think the jury could still be out on which version is more
> readable, but I don't understand the
Charlie Taylor wrote:
flow = integrate(lambda x: 2.0*pi * d(x)* v(x) * sin(a(x)),xBeg, xEnd)
def _flow_func(x):
return 2.0 * pi * d(x) * v(x) * sin(a(x))
flow = integrate(_flow_func, xBeg, xEnd)
root = findRoot(xBeg, xEnd,
lambda x: y2+ lp*(x-x2) -wallFunc( x )[0], tolerance=1.0E-15)
d
"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
Charlie Taylor wrote:
root = findRoot(xBeg, xEnd,
lambda x: y2+ lp*(x-x2) -wallFunc( x )[0], tolerance=1.0E-15)
Um, so which parts of this are the actual lambda?? Just from reading
that, it's hard to be sure. My mind keeps wanting to break at 'lambda
x: y2 + lp*(x-x2)', but when I sto
Harlin Seritt wrote:
Charlie Taylor wrote:
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) -wallF
On Fri, 17 Dec 2004 15:58:09 -0800, Charlie Taylor <[EMAIL PROTECTED]> wrote:
>
> 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 = findRo
Charlie Taylor wrote:
>
> 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) -wallFu
On Fri, 17 Dec 2004 15:58:09 -0800, Charlie Taylor <[EMAIL PROTECTED]> wrote:
>
> 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 = find
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)
I hav
37 matches
Mail list logo