newbie: working iwth list of tuples
Paul Rubin
http
Sun Jan 29 01:38:55 EST 2006
"falcon" <shahbazc at gmail.com> writes:
> I forgot to add that I passing a tuple of functions to the reduce
> function but apparently that is not allowed. My guess was that a tuple
> made up of individual (simple) functions might be easier to manipulate
> programatically than a function which has to know the structure of a
> list.
Python really doesn't support this style all that well. Try Haskell.
See also the SICP book, which uses Scheme.
> (My test code)
> x=[('a',1),('a',1),('a',3),('b',1),('b',2),('c',2),('c',3),('c',4)]
> reduce((lambda x,y: x+y,lambda x,y: x+y),x)
I can't even tell what you're trying to do there.
More information about the Python-list
mailing list