Pythonic way to sum n-th list element?
Alex Martelli
aleax at aleax.it
Mon Apr 28 10:54:29 EDT 2003
Steve Holden wrote:
> "Alex Martelli" <aleax at aleax.it> wrote in message
> news:3japa.44301$LB6.997057 at news1.tin.it...
>
> [why Tim and Guido are dead good ...]
...
>> & ( # conditions for a weak-notrump opener
>> s ( 1 g 4 3 3 3 # shape 4333 (any), or...
>> 2 g 4 4 3 2 # 4432 (any), or...
>> 3 3- 3- 3- 5 # 5332 w 5 clubs, or...
>> 4 3- 3- 5 3- # 5332 w 5 diamonds;
>> )
>> < ( 11 # moreover, a 12-14 range for
>> \+ SHDC c( 4 3 2 1 0) # normal Milton-Work point-count
>> 15
>> )
>> )
>>
>> There -- aren't you glad I don't do language design any more?-)
>
> On this evidence it's arguable that you never did! This language was
> *designed*?
Well yes. Got anything against prefix-notation? I just found it
marginally easier to parse FUNC ( ARGUMENTS ) than (FUNC ARGUMENTS),
otherwise it would have been a bit more Lisp-ish in terms of syntax.
\FUNC <suits> <expression> "scans" the expression over the suits
(Spades, Hearts, Diamonds, Clubs, in this case) and "reduces" the
tuple of results by passing them as ARGUMENTS to the given FUNC --
making this somewhat germane to the thread's Subject;-)... it IS
rather like reduce(func, [expr(suit) for suit in suits]), except,
more compact because that's such a common construct in evaluating
a bridge hand;-).
> but-anyway-let's-all-be-grateful-for-python-ly y'rs - steve
Hmmm, yes, definitely, let's;-).
Alex
More information about the Python-list
mailing list