From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling)
Date: Tue,  4 May 1999 13:28:13 -0400 (EDT)
Subject: [Question] Functional style with lists
In-Reply-To: <372F2B01.25E0ECDD@lirmm.fr>
References: <372F2B01.25E0ECDD@lirmm.fr>
Message-ID: <14127.11676.996615.798921@amarok.cnri.reston.va.us>
X-UID: 1936                                                 

David Berthelot writes:
>I would like to sum the numeric values by using map.
>I've tried this:
>>>> map(lamda x,y:x+y,map(L.getitem,(1,)*len(L)))
>But of course it doesn't work...

	The reduce() built-in does this sort of thing.  Try:
>>> reduce(lambda total,(name,amt): total + amt, L, 0)
75

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
I'm an excuse for medical experiments and art theory. You must get me out of
here and out of the hospital.
    -- Peter Greenaway, _A Zed and Two Noughts_ (1986)





