473,848 Members | 1,568 Online

# Calling J from Python

It is quite easy to call J from Python

Feb 5 '07
50 2928
Dennis Lee Bieber wrote:
On Mon, 05 Feb 2007 17:52:27 +0100, Bjoern Schliessmann
<us************ **************@ spamgourmet.com declaimed the following
in comp.lang.pytho n:
>Mh, just looking at some "advanced" J source taken from
wikipedia.or g makes me feel sick:

| Here's a J program to calculate the average of a list of numbers:
| avg=: +/ % #
| avg 1 2 3 4
| 2.5
That looks like some variation of APL
my colleague informs me that it is indeed associated with some of the same
people if not with Mr Iverson.
--
Robin Becker

Feb 5 '07 #11
Robin Becker <ro***@reportla b.comwrites:
Dennis Lee Bieber wrote:
On Mon, 05 Feb 2007 17:52:27 +0100, Bjoern Schliessmann
<us************ **************@ spamgourmet.com declaimed the following
in comp.lang.pytho n:
Mh, just looking at some "advanced" J source taken from
wikipedia.org makes me feel sick:

| Here's a J program to calculate the average of a list of numbers:
| avg=: +/ % #
| avg 1 2 3 4
| 2.5
That looks like some variation of APL

my colleague informs me that it is indeed associated with some of the same
people if not with Mr Iverson.
The late Ken Iverson designed both J and APL (he has also written an number of

'as

Feb 5 '07 #12
Larry Bates <la*********@we bsafe.comwrites :
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

Feb 5 '07 #13
Diez B. Roggisch wrote:
m =: >@(0&{)
v =: >@(1&{)
h =: >@(2&{)
qu =: >@(3&{)
z =: i.@0:
ret =: |.@}:
init =: z;z;z;i.
f1m =: (m,{.@qu);v;h;} .@qu
f5m =: (z;(v,{:@m);h;q u,ret@m) @ (f1m^:5)
f1h =: (z;z;(h,{:@v);( qu,ret@v)) @ (f5m^:12)
f12h =: (z;z;z;qu,ret@h ,{:@h) @ (f1h^:12)
perm =: qu @ f12h @ init
ord =: *./ @ (#&>"_) @ C.
days =: -: @ ord @ perm
http://www.jsoftware.com/jwiki/Essay..._Clock_Problem
Diez
Why dont they call it "smiley" ?

Operators: :-) :) :o) :-\$ *<Â¦:O) XD -_- +_+ ^_^ *_* !_!
>_< =_= o_o X_X -_o ;) \$_\$ <_< >_ o_0
<_>< ?_? '_' O.O \$.\$ T.T ._. u.u >-<" =] {-_-}

(source: http://en.wikipedia.org/wiki/Smiley )
Feb 5 '07 #14
Alexander Schmolck wrote:
Apart from being less to type
Cool. 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
Is there any regularity in this? If it is, it's not obvious at all.

Regards,
Björn

--
BOFH excuse #78:

Yes, yes, its called a design limitation

Feb 5 '07 #15
>
Mh, just looking at some "advanced" J source taken from
wikipedia.org makes me feel sick:

| Here's a J program to calculate the average of a list of numbers:
| avg=: +/ % #
| avg 1 2 3 4
| 2.5
And here is the Python way of calculating the average
>>mean([1,2,3,4])
2.5

sorry, I don't see any advantage.

cheers,
Stef Mientki
Feb 5 '07 #16
Gosi a écrit :
On Feb 5, 2:59 pm, "Diez B. Roggisch" <d...@nospam.we b.dewrote:
>>Gosi wrote:
>>>It is quite easy to call J from Python

What is J, and why should we care?

Diez

J is in many ways similar to Python.

J has very many advanced operations.

http://www.jsoftware.com/
"""
Our policy on source for our binaries is between the extremes of
Microsoft proprietary source and Linux open source. You can have the
benefits of open source for J binaries, but under a license and a fee.
"""

Good bye J.
Feb 5 '07 #17
Gosi a écrit :
On Feb 5, 2:59 pm, "Diez B. Roggisch" <d...@nospam.we b.dewrote:
>>Gosi wrote:
>>>It is quite easy to call J from Python

What is J, and why should we care?

Diez

J is in many ways similar to Python.
So are Javascript and Ruby.
J has very many advanced operations.

Feb 5 '07 #18
Alexander Schmolck a écrit :
Larry Bates <la*********@we bsafe.comwrites :

>>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
Would my beloved wife's life depend on it, I just couldn't say what all
this garbage is supposed to mean. If that's supposed to be "superior",
I'm quite happy with my inferior favorite languages...
Feb 5 '07 #19
Diez B. Roggisch a écrit :
Gosi wrote:

>>On Feb 5, 2:59 pm, "Diez B. Roggisch" <d...@nospam.we b.dewrote:
>>>Gosi wrote:

It is quite easy to call J from Python

What is J, and why should we care?

Diez

J is in many ways similar to Python.

J has very many advanced operations.

What exactly do you call "similar to python" when the following is a program
written in it? Compared to that, even Perl is a wonder of readability...

m =: >@(0&{)
v =: >@(1&{)
h =: >@(2&{)
qu =: >@(3&{)
z =: i.@0:
ret =: |.@}:
init =: z;z;z;i.
f1m =: (m,{.@qu);v;h;} .@qu
f5m =: (z;(v,{:@m);h;q u,ret@m) @ (f1m^:5)
f1h =: (z;z;(h,{:@v);( qu,ret@v)) @ (f5m^:12)
f12h =: (z;z;z;qu,ret@h ,{:@h) @ (f1h^:12)
perm =: qu @ f12h @ init
ord =: *./ @ (#&>"_) @ C.
days =: -: @ ord @ perm
Yuck. I'd rather program in b**k.

Feb 5 '07 #20

This thread has been closed and replies have been disabled. Please start a new discussion.