merits of Lisp vs Python

André Thieme address.good.until.2006.dec.22 at justmail.de
Fri Dec 15 10:25:32 EST 2006


Christophe Cavalaria schrieb:
> Paul Rubin wrote:
> 
>> André Thieme <address.good.until.2006.dec.22 at justmail.de> writes:
>>> def nif(num, pos, zero, neg):
>>>    if num > 0:
>>>      return pos
>>>    else:
>>>      if num == 0:
>>>        return zero
>>>      else:
>>>        return neg
>> def nif(num, pos, zero, neg):
>>    return (neg, zero, pos)[cmp(num, 0)+1]
> Since we are in one liners, let's be even smarter and do it like that :
> 
> def nif(num, pos, zero, neg):
>    return (zero, pos, neg)[cmp(num, 0)]

Okay, that reduces the complexity of the Python version to that of Lisp.
Now both have the same token count.


André
-- 



More information about the Python-list mailing list