Do I need a nested lambda to do this?

R. C. James Harlow james at wrong.nu
Mon Apr 25 20:27:41 EDT 2005


On Tuesday 26 April 2005 00:34, raoul wrote:
> I can't figure this one out. Trying to be unnecessarily functional I
> suspect.

With list comprehensions:

Python 2.3.4 (#1, Mar 26 2005, 20:54:10)
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> vals = [1.000,2.344,4.2342]
>>> tabs = [((0,1),(0,3),(0,4)),
...        ((2,2),(3,0),(3,9)),
...        ((3,4),(6,3),(7,1))]
>>> [(tuple([(vals[index],subtab[1]) for subtab in tab])) for index,tab in 
enumerate(tabs)]
[((1.0, 1), (1.0, 3), (1.0, 4)), ((2.3439999999999999, 2), 
(2.3439999999999999, 0), (2.3439999999999999, 9)), ((4.2342000000000004, 4), 
(4.2342000000000004, 3), (4.2342000000000004, 1))]



More information about the Python-list mailing list