[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: map/filter/reduce/lambda opinions and background unscientific
From: Ron Adam <rrr () ronadam ! com>
Date: 2005-07-08 3:25:57
Message-ID: 9nmze.144208$VH2.52770 () tornado ! tampabay ! rr ! com
[Download RAW message or body]
Christopher Subich wrote:
> As others have mentioned, this looks too much like a list comprehension
> to be elegant, which also rules out () and {}... but I really do like
> the infix syntax.
Why would it rule out ()?
You need to put a lambda express in ()'s anyways if you want to use it
right away.
print (lambda x,y:x+y)(1,2)
If you don't use the ()'s it reads the y(1,2) as part of the lambda
expression, might as well require the ()'s to start with rather than
leave it open for a possible error.
You could even say () is to function as [] is to list.
a function : name(args) -> returns a value
a list : name[index] -> returns a value
My choice:
name = (let x,y return x+y) # easy for beginners to understand
value = name(a,b)
value = (let x,y return x+y)(a,b)
I think the association of (lambda) to [list_comp] is a nice
distinction. Maybe a {dictionary_comp} would make it a complete set. ;-)
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic