473,848 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling J from Python

It is quite easy to call J from Python

http://groups.google.com/group/J-Pro...84b75667f5f64e

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
freely downloadable math books using J, see jsoftware.com).

'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

http://groups.google.com/group/J-Pro...ead/thread/5e8...

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

http://groups.google.com/group/J-Pro...ead/thread/5e8...

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.
what's an "advanced operation" ?

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

http://groups.google.com/group/J-Pro...ead/thread/5e8...

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.

Similar topics

3
1648
by: Bill Orcutt | last post by:
Having seen the number of lost souls asking questions about embedding Python in the archives of this group, I hesitate to add myself to their number, but I've hit a problem I can't quite get my head around. I have a simple C program that embeds a python interpreter to execute python commands and return stdout, and to a point everything works as intended. The problem that each command seems to be executed in its own context and knows...
0
2329
by: Natsu Mizutani | last post by:
Hello, I'm trying to wrap a c++ library using MPI inside with boost.python (or SWIG). I managed to find that calling `MPI::Init()` embeded in a c++ funtion would not work. So, I decided to use `pyMPI`. To avoid overhead of pickling and unpickling while calling `mpi.send` in Python, I'd rather call c++ functions `MPI::Isend()` etc. embeded in a c++ function.
2
2404
by: Satish Chimakurthi | last post by:
Hi all, My question is surely a basic one, but somehow, I am not able to figure it out. I have a python file "satish.py" as follows: *satish.py* def main(): y()
9
3775
by: F. GEIGER | last post by:
I've dev'ed a Python prototype of an app, that besides the internals making it up has a gui. While test-driven dev'ing the app's internals in Python is fun as usual, dev'ing the GUI is not so funny, at least for me. I guess dev'ing a GUI in a test-driven way is not possible, or is it? I'm using wxPython, so if anyone has an idea... For now most of the time I extend and change the gui things, then run it, do the clicks to go thru the...
11
9112
by: Kamilche | last post by:
What a debug nightmare! I just spent HOURS running my script through the debugger, sprinkling in log statements, and the like, tracking down my problem. I called a function without the ending parentheses. I sure do WISH Python would trap it when I try to do the following: MyFunc instead of:
1
1585
by: Stephen Kellett | last post by:
Hello everyone, I'm trying to do something in C calling Python and its failing. I'd be grateful if you could take a look and hopefully you have an answer. What I'm trying to do is determine the address of the "collect" function in the "gc" module. I want to do this so that we can determine when a garbage collection happens, regardless of how it is triggered (explicitly by a user call, or implicitly by the behaviour of the program...
1
1930
by: Gerald Klix | last post by:
I read the whol email thread carefully and could not find any sentence by Guido, which states that he does not accept ctypes for the standard library. He just declined to rewrite winreg. Did I miss something? Cya, Gerald -----Ursprüngliche Nachricht----- Von: python-list-bounces+gerald.klix=klix.ch@python.org Im Auftrag von
10
13313
by: Finger.Octopus | last post by:
Hello, I have been trying to call the super constructor from my derived class but its not working as expected. See the code: class HTMLMain: def __init__(self): self.text = "<HTML><BODY>"; print(self.text); def __del__(self): self.text = "</BODY></HTML>"; print(self.text);
47
5000
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both and my c++ code should call c code.but when i tried to call a function in c code externing that function in my c++ code, i am getting unresolved external symbol error. Whatever i try its giving more and more errrors...so is it possible to merge 2...
16
3792
by: Jaco Naude | last post by:
Hi there, This is my first post over here and I hope someone can give me some guidance. I'm trying to embed Python into a Visual C++ 2008 application and I'm getting linker problems. I've compiled a DLL of the Python source code using the pythoncode VC++ project in the PCbuild folder of the source download and this works 100% without any warnings etc. I've done this in Debug and Release mode without any problems.
0
9892
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10997
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10661
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10718
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9497
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7067
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5917
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4134
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3172
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.