On Jul 14, 2009, at 3:35 PM, William Stein wrote:

> 2009/7/14 Carlos Córdoba <ccordob...@gmail.com>:
>> Thanks John, I'd seen Python comprehensions before, but since I  
>> was trying
>> to do all in a one-liner, I think I overlooked your elegant and  
>> simple
>> solution. One comprehension at a time is quite neat, but several  
>> is just
>> unreadable.
>
> That could be a function of familiarity.  Quick poll -- Do you find
> the following "just unreadable"?
>
> x = [1,2,3]
> y = [2*a for a in x]
> z = [b + 3 for b in y]
> w = [a/max(z) for a in z]
> v = [[cos(a), sin(a)] for a in w]
>
> ANSWER:
> [ ] Yes, the above is just unreadable.
> [X] No, I can read the above just fine.  It is crystal clear.

(For what a second data point is worth...)

I'd probably write it a bit more compactly, similar to John  
Palmieri's version.

- Robert


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to