Calling J from Python

Alexander Schmolck a.schmolck at gmail.com
Mon Feb 5 13:17:31 EST 2007


Larry Bates <larry.bates at websafe.com> writes:

> And why is that superior to this:
> 
> def avg(l):
>     return float(sum(l))/len(l)
> 
> >>>avg([1,2,3,4])
> 2.5

Apart from being less to type and it is superior in that it's generalizes much
better, e.g:

avg&.^.   NB. geomtric mean
avg&.%    NB. harmonic mean
avg M     NB. column mean of matrix M
avg"1 M   NB. row mean of matrix M

'as




More information about the Python-list mailing list