473,386 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Calling J from Python

It is quite easy to call J from Python

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

Feb 5 '07 #1
50 2815
Gosi wrote:
It is quite easy to call J from Python

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

What is J, and why should we care?

Diez
Feb 5 '07 #2
On Feb 5, 2:59 pm, "Diez B. Roggisch" <d...@nospam.web.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/

Feb 5 '07 #3
Gosi wrote:
J is in many ways similar to Python.
The only one I see at the moment is that they're both some kind of
programming languages.
J has very many advanced operations.
Sure.

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

In the meantime, do you now have an answer to why we should care?

Regards,
Björn

--
BOFH excuse #314:

You need to upgrade your VESA local bus to a MasterCard local bus.

Feb 5 '07 #4
hg
Bjoern Schliessmann wrote:
Gosi wrote:
>J is in many ways similar to Python.

The only one I see at the moment is that they're both some kind of
programming languages.
>J has very many advanced operations.

Sure.

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

In the meantime, do you now have an answer to why we should care?

Regards,
Björn

--
BOFH excuse #314:

You need to upgrade your VESA local bus to a MasterCard local bus.

Be nice !

Feb 5 '07 #5

GosiJ is in many ways similar to Python.

GosiJ has very many advanced operations.

Gosihttp://www.jsoftware.com/

Doesn't look like open source of any variety. If a person uses Python with
various add-ons (RPy, numpy, matplotlib, etc) why would they want to switch
to a closed source product?

Skip
Feb 5 '07 #6
Gosi wrote:
On Feb 5, 2:59 pm, "Diez B. Roggisch" <d...@nospam.web.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;qu,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
Feb 5 '07 #7
On Feb 5, 12:23 pm, "Diez B. Roggisch" <d...@nospam.web.dewrote:
Gosi wrote:
On Feb 5, 2:59 pm, "Diez B. Roggisch" <d...@nospam.web.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...

(cryptic gibberish snipped)

http://www.jsoftware.com/jwiki/Essay..._Clock_Problem

Diez
Please avoid posting code looking like garbled profanities in c.l.py.
This was outright offensive.

George

Feb 5 '07 #8
sk**@pobox.com writes:
GosiJ is in many ways similar to Python.

GosiJ has very many advanced operations.

Gosihttp://www.jsoftware.com/

Doesn't look like open source of any variety. If a person uses Python with
various add-ons (RPy, numpy, matplotlib, etc) why would they want to switch
to a closed source product?
You wouldn't, if for nothing else because python has far better scientific
libraries. If you've got an interest in programming languages as such J (or
some other APL) is worth a look though; it's also handy for quick mathematical
experimentation (J's array primitives are more expressive than what numpy
offers and python doesn't support rationals, so it's not just concise due to
perl-style crypticness). For example I once wrote this (slow) code to display
part of a mandelbrot fractal:

load'viewmat'
viewmat+/2&>:|((j.~/~(%~i:)99)&+@:*:)^:(i.32)0

It'll likely require you more typing in python, but then you'd need to do such
things quite a lot for seeing an amortization in terms of less time spent with
your PC; I think most people will find they need a seizable learning
investment to get anywhere with J and python already is very expressive for
the kind of things J is good at.

'as

Feb 5 '07 #9
Bjoern Schliessmann wrote:
Gosi wrote:
>J is in many ways similar to Python.

The only one I see at the moment is that they're both some kind of
programming languages.
>J has very many advanced operations.

Sure.

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

In the meantime, do you now have an answer to why we should care?

Regards,
Björn
And why is that superior to this:

def avg(l):
return float(sum(l))/len(l)
>>>avg([1,2,3,4])
2.5
Which can actually be read and debugged in the future!

-Larry
Feb 5 '07 #10
Dennis Lee Bieber wrote:
On Mon, 05 Feb 2007 17:52:27 +0100, Bjoern Schliessmann
<us**************************@spamgourmet.comdecla imed the following
in comp.lang.python:
>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.
--
Robin Becker

Feb 5 '07 #11
Robin Becker <ro***@reportlab.comwrites:
Dennis Lee Bieber wrote:
On Mon, 05 Feb 2007 17:52:27 +0100, Bjoern Schliessmann
<us**************************@spamgourmet.comdecla imed the following
in comp.lang.python:
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*********@websafe.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;qu,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.web.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.web.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
Larry Bates a écrit :
>
def avg(l):
return float(sum(l))/len(l)

>>>>avg([1,2,3,4])

2.5
def avg(*args):
return float(sum(args)) / len(args))
>
Which can actually be read and debugged in the future!
in_my_arms(tm)
Feb 5 '07 #19
Alexander Schmolck a écrit :
Larry Bates <la*********@websafe.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 #20
Diez B. Roggisch a écrit :
Gosi wrote:

>>On Feb 5, 2:59 pm, "Diez B. Roggisch" <d...@nospam.web.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;qu,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 #21
Bjoern Schliessmann <us**************************@spamgourmet.comwrite s:
Alexander Schmolck wrote:
Apart from being less to type

Cool. Less to type.
Yes. Readability is more important in many context, but for something designed
for interactive experimentation and exploration little typing is absolutely
essential. Would you use a calculator that would require Java-style
boilerplate to add two numbers?

I'd also venture that readability and typing ease are typically closely
positively correlated (compare python to C++) and although I would not claim
that J is particularly readable I'm also not an expert user (I doubt I would
even then, but I'm sure it *does* make a difference).
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.
Sure. ``f&.g`` is like ``(f o g) o g^-1`` in common mathemetical notation.
``^.`` is log and ``%`` is inversion/division. Making ``&.`` (it's called
"under") available as a convenient abstraction is IMO one really useful
innovation of J.

As for the remaing two: it's similar to numpy in that one and the same
function can normally operate on arrays of different dimensions (including
scalars). In numpy you'd also write stuff like ``mean(M, axis=1)``, it's not
exactly the same, although the axis abstraction comes from APL (another cool
idea), J introduces a slightly different approach. The ``"1`` means "operate
on cells of rank 1" (i.e. vectors), rather than "operate along a certain
axis". For dyadic (2-argument) functions you can also specify different left
and right rank, so you could write the outerproduct v'w thus: ``v *"0 1 w``
(multiply each 0-cell (i.e scalar) of v with each 1-cell (i.e. vector, there
is only one) of w). Unlike the linear algebra notation this readily
generalizes to more than 1 dimensional objects.

BTW I don't think J is an ideal language, not even for numerical computing --
there are plenty of things I'd do differently and that includes measures that
would IMO greatly aid readability (like getting rid of "ambivalence"[1]). But
I have little doubt that, no matter what its flaws may be, APL (and J is
really just an updated, ASCII-based APL) is one of the most innovative and
important programming languages ever conceived. Anyone interested in the
design of programming language for scientific computing ought to take a look
at at least a look at it or one of its descendants.

'as

Footnotes:
[1] Basically almost every J function has a completely different meaning
depending on whether you use it as a unary or binary function (just as
conventionally "-" is abusively used for both substraction and negation).
Feb 5 '07 #22
Alexander Schmolck wrote:
Would you use a calculator that would require Java-style
boilerplate to add two numbers?
This isn't a Java newsgroup, so your metaphor is irrelevant. People use
Python because it *isn't* Java and does not succumb to the problem you
seem to be accusing it of.
Feb 5 '07 #23
Bruno Desthuilliers wrote:
Gosi a écrit :
>On Feb 5, 2:59 pm, "Diez B. Roggisch" <d...@nospam.web.dewrote:
J has very many advanced operations.

what's an "advanced operation" ?
An operation which dont stay in place.

Feb 5 '07 #24
Alexander Schmolck a écrit :
Bjoern Schliessmann <us**************************@spamgourmet.comwrite s:

>>Alexander Schmolck wrote:

>>>Apart from being less to type

Cool. Less to type.


Yes. Readability is more important in many context, but for something designed
for interactive experimentation and exploration little typing is absolutely
essential. Would you use a calculator that would require Java-style
boilerplate to add two numbers?
No, thanks. But hopefully we have Python :

Python 2.4.1 (#1, Jul 23 2005, 00:37:37)
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on
linux2
Type "help", "copyright", "credits" or "license" for more information.
>>3 + 4
7
>>>
!-)
Feb 5 '07 #25
Laurent Pointal a écrit :
Bruno Desthuilliers wrote:

>>Gosi a écrit :
>>>On Feb 5, 2:59 pm, "Diez B. Roggisch" <d...@nospam.web.dewrote:
J has very many advanced operations.

what's an "advanced operation" ?


An operation which dont stay in place.
You meant something like a good camembert ?-)
Feb 5 '07 #26
Bruno Desthuilliers <bd*****************@free.quelquepart.frwrites:
No, thanks. But hopefully we have Python :

Python 2.4.1 (#1, Jul 23 2005, 00:37:37)
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on linux2

Type "help", "copyright", "credits" or "license" for more information.
>>3 + 4
7
>>>
My calculuator even gives a pretty good answer if I divide them (without
importing anything from the __future__).

'as

Feb 5 '07 #27
Alexander Schmolck wrote:
For example I once wrote this (slow) code to display
part of a mandelbrot fractal:

load'viewmat'
viewmat+/2&>:|((j.~/~(%~i:)99)&+@:*:)^:(i.32)0

It'll likely require you more typing in python,
Yes, but with Python you wouldn't have to spend a
couple of weeks sitting and thinking before starting
to type that line...

--
Greg
Feb 6 '07 #28
On Feb 5, 8:48 am, "Gosi" <gos...@gmail.comwrote:
It is quite easy to call J from Python

http://groups.google.com/group/J-Pro...ead/thread/5e8...
There are a couple of issue that should be adressed. Am I going to
jail if I write a program and then redistribute all the files required
to run the program I write?? The second is how do I use the j stuff
without learning all that much about j. I am just intrested in
stealing graphics libraries and using what I have already written in
python..

Feb 6 '07 #29
On Feb 5, 2:48 pm, "Gosi" <gos...@gmail.comwrote:
It is quite easy to call J from Python

http://groups.google.com/group/J-Pro...ead/thread/5e8...
Hii Gosi,
>From reading what has gone before, you seem to have got it in the neck
from some pythonistas.
I'd just like to say from some but not all.

It is *A GOOD THING* that Python has bridges to other languages. Some
may not care to program in the other language - which is a separate
concer;. but a link between the language - be it Haskell or befunge or
J, makes Python better in my view. If your expert J programmers have
need for something that is hard to do in J they might now be more
likely to use Python.

We should remember that Python is a great glue language too, and links
to other languages and tools is how we maintain that position.

- Paddy.

Feb 6 '07 #30
On Feb 6, 3:04 am, "Eric_Dex...@msn.com" <Eric_Dex...@msn.comwrote:
On Feb 5, 8:48 am, "Gosi" <gos...@gmail.comwrote:
It is quite easy to call J from Python
http://groups.google.com/group/J-Pro...ead/thread/5e8...

There are a couple of issue that should be adressed. Am I going to
jail if I write a program and then redistribute all the files required
to run the program I write??
J is free for anyone to download and use.

If someone is interested in putting you in jail it will not because
you distribute J or redistribute the J utilities.
The second is how do I use the j stuff
without learning all that much about j.
Just like Python then how much time you spend is uo to you.

If you want to be good at it you may have to spend some time.

You may also be just a casual user and dip into it now and again.

There are lots of Demos, Labs and Help files besides all the
utilities.

You can freely use the utilities and examples to create your own
application.

You can write code in conventional style and not spend any time on the
advanced functionality.

I am just intrested in
stealing graphics libraries and using what I have already written in
python..
There are a number of graphics examples, utilities and demos you can
use in J and combine it with Python.

The new grid classes in J are amazingly useful too.

I am just starting to learn Python and I find it interesting to
combine it with J.
I know a few people who are doing so successfully.

There are always some nicetise in any language that can be beneficial.
Combining them enhances both.

http://groups.google.com/group/j-programming
http://jsoftware.com/

Feb 6 '07 #31
On Feb 5, 3:48 pm, "Gosi" <gos...@gmail.comwrote:
It is quite easy to call J from Python

http://groups.google.com/group/J-Pro...ead/thread/5e8...
As I understand it, the k language, which is similar to J, is used to
interact with streamed realtime financial data, where I imagine the
terseness of the language may make sense. I messed about with J for a
day or two, and found it interesting and in a way natural (given some
Higher Math background once upon a time).

Here's a link to a company who it looks like could value some
knowledge of J/K/APL type languages: http://www.kx.com/news/in-the-
news.php

All the best

Gerard

Feb 6 '07 #32
Gosi a écrit :
On Feb 6, 3:04 am, "Eric_Dex...@msn.com" <Eric_Dex...@msn.comwrote:
>>On Feb 5, 8:48 am, "Gosi" <gos...@gmail.comwrote:

>>>It is quite easy to call J from Python
>>>http://groups.google.com/group/J-Pro...ead/thread/5e8...

There are a couple of issue that should be adressed. Am I going to
jail if I write a program and then redistribute all the files required
to run the program I write??


J is free for anyone to download and use.
But not to inspect or modify. This is "free" as in "free beer", not as
in "free speech".
>
>>The second is how do I use the j stuff
without learning all that much about j.


Just like Python then how much time you spend is uo to you.

If you want to be good at it you may have to spend some time.

You may also be just a casual user and dip into it now and again.
This is easy with Python, which emphasis readability. I doubt one can
say the same about j.
Feb 6 '07 #33
Gosi:
There are a number of graphics examples, utilities and demos you can
use in J and combine it with Python.
Some of those graphic examples are very nice, I have seen a big site
filled with complex fractals, chaotic attractors, etc.
Python Zen seems somewhat opposed to part of the J spirit, that's why
it's not easy to advertise J in this newsgroup. Python is open source,
and it values readability, it belives that it's better to write more
and be more readable/debuggable, than to be able to express many
things with few symbols. APL was an interesting language, powerful
too, and J looks more keyboard-friendly and it's probably better for
other things too. K seems even less readable than J to me. Probably J
has to be compared more to scipy than to Python itself, because they
share some purposes, the vector/matrix processing. If you need to do
lot of array processing the syntax of scipy (with the help of
MatPlotLib too, that's partially copied from MatLab) isn't (may be
not) high-level enough, the system isn't able to simplify things by
itself, etc. So in that situation a more functional language may be
fitter (maybe even F#, but probably there are better languages around
for that purpose, some modern ones coming from ML family).

Bye,
bearophile

Feb 6 '07 #34
On Feb 6, 9:08 pm, bearophileH...@lycos.com wrote:
Gosi:
There are a number of graphics examples, utilities and demos you can
use in J and combine it with Python.

Some of those graphic examples are very nice, I have seen a big site
filled with complex fractals, chaotic attractors, etc.
Python Zen seems somewhat opposed to part of the J spirit, that's why
it's not easy to advertise J in this newsgroup. Python is open source,
and it values readability, it belives that it's better to write more
and be more readable/debuggable, than to be able to express many
things with few symbols. APL was an interesting language, powerful
too, and J looks more keyboard-friendly and it's probably better for
other things too. K seems even less readable than J to me. Probably J
has to be compared more to scipy than to Python itself, because they
share some purposes, the vector/matrix processing. If you need to do
lot of array processing the syntax of scipy (with the help of
MatPlotLib too, that's partially copied from MatLab) isn't (may be
not) high-level enough, the system isn't able to simplify things by
itself, etc. So in that situation a more functional language may be
fitter (maybe even F#, but probably there are better languages around
for that purpose, some modern ones coming from ML family).

Bye,
bearophile
Ken Iverson created APL and it ran first time on a computer 1966.
Ken Iverson then corrected several things and made it so different
that he could no longer use the name and the results was J around
1990.

J can be very short and effective.

I like to use J for many things and I think that combining Python and
J is a hell of a good mixture.

Feb 7 '07 #35
In <11*********************@v33g2000cwv.googlegroups. com>, Gosi wrote:
I like to use J for many things and I think that combining Python and
J is a hell of a good mixture.
I was able to follow this sentence up to and including the word "hell"… :-)

Ciao,
Marc 'BlackJack' Rintsch
Feb 7 '07 #36
On Feb 7, 3:46 pm, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
In <1170861935.779969.52...@v33g2000cwv.googlegroups. com>, Gosi wrote:
I like to use J for many things and I think that combining Python and
J is a hell of a good mixture.

I was able to follow this sentence up to and including the word "hell"...:-)

Ciao,
Marc 'BlackJack' Rintsch

That is a start.

"Hell" is also what most example start with as in "Hello something"
Hell in northern countries is very cold.
Hell in middle east is very hot.
I do not know which is your Hell hot or cold.
Hell o veröld

Feb 7 '07 #37
Gosi wrote:
On Feb 7, 3:46 pm, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
>In <1170861935.779969.52...@v33g2000cwv.googlegroups. com>, Gosi wrote:
>>I like to use J for many things and I think that combining Python and
J is a hell of a good mixture.
I was able to follow this sentence up to and including the word "hell"... :-)

Ciao,
Marc 'BlackJack' Rintsch


That is a start.

"Hell" is also what most example start with as in "Hello something"
Hell in northern countries is very cold.
Hell in middle east is very hot.
I do not know which is your Hell hot or cold.
Hell o veröld
It's also a village in Norway: http://en.wikipedia.org/wiki/Hell,_Norway
:D
Feb 8 '07 #38
Tina I wrote:
.......
It's also a village in Norway: http://en.wikipedia.org/wiki/Hell,_Norway
In German it's bright
--
Robin Becker

Feb 8 '07 #39
I may have mistook the source code licence for the use licence.. I
will look into a little further to see what it can do.. Looks like
you are not allowed to redistribute k for profit. Some day I will
look up letters a random in the search engine to see what I come up
with.
On Feb 6, 2:05 am, "Gosi" <gos...@gmail.comwrote:
On Feb 6, 3:04 am, "Eric_Dex...@msn.com" <Eric_Dex...@msn.comwrote:
On Feb 5, 8:48 am, "Gosi" <gos...@gmail.comwrote:
It is quite easy to call J from Python
>http://groups.google.com/group/J-Pro...ead/thread/5e8...
There are a couple of issue that should be adressed. Am I going to
jail if I write a program and then redistribute all the files required
to run the program I write??

J is free for anyone to download and use.

If someone is interested in putting you in jail it will not because
you distribute J or redistribute the J utilities.
The second is how do I use the j stuff
without learning all that much about j.

Just like Python then how much time you spend is uo to you.

If you want to be good at it you may have to spend some time.

You may also be just a casual user and dip into it now and again.

There are lots of Demos, Labs and Help files besides all the
utilities.

You can freely use the utilities and examples to create your own
application.

You can write code in conventional style and not spend any time on the
advanced functionality.
I am just intrested in
stealing graphics libraries and using what I have already written in
python..

There are a number of graphics examples, utilities and demos you can
use in J and combine it with Python.

The new grid classes in J are amazingly useful too.

I am just starting to learn Python and I find it interesting to
combine it with J.
I know a few people who are doing so successfully.

There are always some nicetise in any language that can be beneficial.
Combining them enhances both.

http://groups.google.com/group/j-pro...jsoftware.com/

Feb 8 '07 #40
On Feb 8, 12:00 pm, "Eric_Dex...@msn.com" <Eric_Dex...@msn.comwrote:
I may have mistook the source code licence for the use licence.. I
will look into a little further to see what it can do.. Looks like
you are not allowed to redistribute k for profit. Some day I will
look up letters a random in the search engine to see what I come up
with.

On Feb 6, 2:05 am, "Gosi" <gos...@gmail.comwrote:
On Feb 6, 3:04 am, "Eric_Dex...@msn.com" <Eric_Dex...@msn.comwrote:
On Feb 5, 8:48 am, "Gosi" <gos...@gmail.comwrote:
It is quite easy to call J from Python
http://groups.google.com/group/J-Pro...ead/thread/5e8...
There are a couple of issue that should be adressed. Am I going to
jail if I write a program and then redistribute all the files required
to run the program I write??
J is free for anyone to download and use.
If someone is interested in putting you in jail it will not because
you distribute J or redistribute the J utilities.
The second is how do I use the j stuff
without learning all that much about j.
Just like Python then how much time you spend is uo to you.
If you want to be good at it you may have to spend some time.
You may also be just a casual user and dip into it now and again.
There are lots of Demos, Labs and Help files besides all the
utilities.
You can freely use the utilities and examples to create your own
application.
You can write code in conventional style and not spend any time on the
advanced functionality.
I am just intrested in
stealing graphics libraries and using what I have already written in
python..
There are a number of graphics examples, utilities and demos you can
use in J and combine it with Python.
The new grid classes in J are amazingly useful too.
I am just starting to learn Python and I find it interesting to
combine it with J.
I know a few people who are doing so successfully.
There are always some nicetise in any language that can be beneficial.
Combining them enhances both.
http://groups.google.com/group/j-pro...jsoftware.com/
You can get older versions of the source code too for free.
The utility sources are also free.

Feb 8 '07 #41
"Tina I" <ti*****@bestemselv.comwrote:
Gosi wrote:
On Feb 7, 3:46 pm, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
>In <1170861935.779969.52...@v33g2000cwv.googlegroups. com>, Gosi wrote:
>>I like to use J for many things and I think that combining Python and
J is a hell of a good mixture.
I was able to follow this sentence up to and including the word "hell"...
:-)
>>
Ciao,
Marc 'BlackJack' Rintsch


That is a start.

"Hell" is also what most example start with as in "Hello something"
Hell in northern countries is very cold.
Hell in middle east is very hot.
I do not know which is your Hell hot or cold.
Hell o veröld
It's also a village in Norway: http://en.wikipedia.org/wiki/Hell,_Norway
:D

I am under the impression that Loki had a daughter called Hel ...

- Hendrik
Feb 9 '07 #42
Hendrik van Rooyen wrote:
>
I am under the impression that Loki had a daughter called Hel ...

- Hendrik
Yes. And Hel was the queen of the underworld which was also called 'Hel'
(Which of course is 'hell', in modern Norwegian : "helvete")

Feb 9 '07 #43
Ant
On Feb 6, 12:21 am, greg <g...@cosc.canterbury.ac.nzwrote:
....
Yes, but with Python you wouldn't have to spend a
couple of weeks sitting and thinking before starting
to type that line...
This is a good point often overlooked. You often get these threads on
c.l.python about "How can I do this in one line", usually with some
example of how it is done in only 13 characters in Perl. Yes you may
spend less time typing - but unless you are a true expert in (J, Perl,
other terse language) the time you spend actually working out how to
type it, and in debugging it far outweighs the time you'd spend on all
of that typing in a clean but more verbose language such as Python.
Feb 9 '07 #44
[restoring context]
"Ant" <an****@gmail.comwrites:
On Feb 6, 12:21 am, greg <g...@cosc.canterbury.ac.nzwrote:

Alexander Schmolck wrote:
For example I once wrote this (slow) code to display
part of a mandelbrot fractal:
load'viewmat'
viewmat+/2&>:|((j.~/~(%~i:)99)&+@:*:)^:(i.32)0
It'll likely require you more typing in python,
Yes, but with Python you wouldn't have to spend a
couple of weeks sitting and thinking before starting
to type that line...
(it's actually reasonably straightforward, if someone really cares I might
post a translation)
>
This is a good point often overlooked.
There is of course some truth in Greg's statement -- J code will likely have a
higher thought/character ratio (even after adjusting for differences in
average token-length) -- but I don't think that is in itself terribly
interesting.

What is in my opinion of interest is how much of the additional thought you
need to put in in order to achieve higher terseness is spent

a) on more pentrating insight on the problem as such, encouraged by the
mind-set and abstractions associated with a language (let's call this
expressiveness)

and how much of it is spent

b) on perl-golf style geek masturbation that focuses on recalling and
exploiting the language's various behavioral oddities that are only of
coincidental or low-level relevance to the problem (let's call this
golf-syndrome)

I'm not claiming that the boundaries between the two are always unambigious,
but I think the distinction is pretty important when discussing pros and cons
of differences in terseness between languages.

Apart from scaling better, one reason that a), expressiveness, is much more
interesting than b), golf-syndrome, is that it translates to some extent even
to writing code in other languages as it enriches the programmer's reservoir
of metaphors and abstractions. Typically this also has a beneficial effect
for coding even in languages that offer no direct support for these
abstractions (I bet a programmer with, say extensive python, J and prolog
experience and just a little bit of C background is in many cases likely to
come up with a superior C solutions to challenging problems than someone who's
got the same amount of experience in C only).

Therefore...
You often get these threads on c.l.python about "How can I do this in one
line", usually with some example of how it is done in only 13 characters in
Perl. Yes you may spend less time typing - but unless you are a true expert
in (J, Perl, other terse language) the time you spend actually working out
how to type it, and in debugging it far outweighs the time you'd spend on
all of that typing in a clean but more verbose language such as Python.
.... I also don't think your pairing of J and Perl is particularly helpful. As
long as no one can point me to some resonable examples demonstrating otherwise
I flattly deny that Perl is more concise than python in an *interesting* way,
i.e. by encouraging or enabling a)

(BTW "not interesting" != "not practically relevant"; harking back to my
previous posts, typing effort *does matter* in some contexts, such as
command-line one-liners; IMO the only thing perl is useful for.)

J, on the other hand, whilst also suffering somewhat from golf-syndrome, does
in my opinion also enable a)-style terseness. Let me give an example:

Before reading further, how would you code a program that gives the following
output ('skewed' sierpinski-triangle) in python? I'll give some remarkably
concise and IMO lucid J code and a python translation below.
*
**
* *
****
* *
** **
* * * *
********
* *
** **
* * * *
**** ****
* * * *
** ** ** **
* * * * * * * *
****************


SPOILERS AHEAD











J solution
----------

I can think of two nice ways in J, 13 and 16 characters long respectively and
each expressing something essential and non-trival about the problem in a way
that would be more cumbersome in python.

Here's the first one:

(,,.~)^:4,'*' NB. due to Cliff Reiter, slightly adapted
Possible Python translation
---------------------------

Here's a python transiteration attempt:

# ^: , ~ ,.
print rep(hook(vertcat, self(horzcat)),4)('*')

or slightly more idiomatic:

def sierpinski(x):
return vertcat(x,horzcat(x,x))

print rep(sierpinsky,4)('*')

With:

def identity(x): return x
def rep(f,n): # f^:n
if n < 0: return lambda *args: rep(inverse(f),-n)(*args)
elif n == 0: return identity
else: return lambda *args: rep(f,n-1)(f(*args))
# horzcat and vertcat are only string-based special purpose mockups for this
# problem since python doesn't have arrays
def horzcat(a,b): # a,.b
return "\n".join(a_i+b_i for (a_i,b_i) in zip(a.split('\n'),
b.split('\n')))
def vertcat(a,b): # a,b
# fill "rows" of b up with spaces if a's rows are longer and vice versa
dif = len(a.split('\n')[0]) - len(b.split('\n')[0])
if dif < 0:
a = a.replace('\n', ' '*-dif + '\n') + ' '*-dif
elif dif 0:
b = b.replace('\n', ' '*dif + '\n') + ' '*dif
return a + '\n' + b
def self(f): # f~
return lambda x: f(x,x)
def hook(f,g): # (f g)
return lambda x: f(x,g(x))
print rep(hook(vertcat, self(horzcat)),4)('*')

I find above J solution is quite neat conceptually because it directly
captures the self-similarity.

The other J solution is

' *'{~2|!~/~i.*:2^4

Can you figure out how it works? (Hint: k!n = choose(k,n), 2|x = x%2)

'as
Feb 9 '07 #45
Alexander

Alexander Schmolck <a.********@gmail.comwrites:
I can think of two nice ways in J, 13 and 16 characters long respectively and
each expressing something essential and non-trival about the problem in a way
that would be more cumbersome in python.

Here's the first one:

(,,.~)^:4,'*' NB. due to Cliff Reiter, slightly adapted
Well, not as interesting as your solution, but definitively less mind-boggling
and much more flexible/extendible

================================================== ==
l = [True]
pr = {True: '*', False: ' '}

for k in range(15):
print ''.join([pr[x] for x in l])
l = [True] + [l[i+1]^l[i] for i in range(len(l)-1)] + [True]
================================================== ==

more elegant solutions sought!

tnoo
Feb 9 '07 #46
ant:
and in debugging it far outweighs the time you'd spend on all
of that typing in a clean but more verbose language such as Python.
Typing time counts a bit too. A language like Java is even more
verbose than Python, and that probably slows down the actual
programming, compared to less verbose languages. I think there is some
verbosity sweet spot between J and Java, and for me that's called
Python ;-)
Martin Lüthi:
more elegant solutions sought!
This is a bit simpler, but probably there are simpler solutions using
modular arithmetic:

l = [1]
for _ in range(15):
print ''.join(" *"[x] for x in l)
l = [1] + [l[i+1]^l[i] for i in range(len(l)-1)] + [1]
Bye,
bearophile

Feb 10 '07 #47
On Feb 9, 9:20 pm, bearophileH...@lycos.com wrote:
ant:
and in debugging it far outweighs the time you'd spend on all
of that typing in a clean but more verbose language such as Python.

Typing time counts a bit too. A language like Java is even more
verbose than Python, and that probably slows down the actual
programming, compared to less verbose languages. I think there is some
verbosity sweet spot between J and Java, and for me that's called
Python ;-)

Martin Lüthi:
more elegant solutions sought!

This is a bit simpler, but probably there are simpler solutions using
modular arithmetic:

l = [1]
for _ in range(15):
print ''.join(" *"[x] for x in l)
l = [1] + [l[i+1]^l[i] for i in range(len(l)-1)] + [1]

Bye,
bearophile
Here's another one, adapted from the example (in Java) in Wikipedia's
entry (http://en.wikipedia.org/wiki/Sierpinski_triangle):

N=15
for x in xrange(N,0,-1):
print ''.join('* '[x&y!=0] for y in xrange(N+1-x))
George

Feb 10 '07 #48
"Dennis Lee Bieber" <wl*****@ix.netcom.comwrote:
On Thu, 8 Feb 2007 10:55:17 +0200, "Hendrik van Rooyen"
<ma**@microcorp.co.zadeclaimed the following in comp.lang.python:
I am under the impression that Loki had a daughter called Hel ...
One of his few "normal" offspring... After all, Loki also was
Sleipnir's* /mother/! And probably related to Fenrir (aka, the Fenris
Wolf) as well.
* Odin's eight-legged horse
We should both be more careful - using the past tense like that is
disrespectful, and there are no guarantees that the Norse gods are dead.

Vindictive lot, they were.. ....uuhhh are, I mean.

- Hendrik

Feb 10 '07 #49
Alexander Schmolck wrote:
how would you code a program that gives the following
output ('skewed' sierpinski-triangle) in python?
*
**
* *
****
* *
** **
* * * *
********
* *
** **
* * * *
**** ****
* * * *
** ** ** **
* * * * * * * *
****************
################################################## #############

def print_sierpinski(order):
size = 4 * 2 ** order
buffer = [size * [" "] for i in range(size)]
put_sierpinski(buffer, size, 0, 0)
for line in buffer:
print "".join(line)

def put_sierpinski(buffer, size, x, y):
if size == 4:
put_triangle(buffer, size, x, y)
else:
size2 = size / 2
put_sierpinski(buffer, size2, x, y)
put_sierpinski(buffer, size2, x, y + size2)
put_sierpinski(buffer, size2, x + size2, y + size2)

def put_triangle(buffer, size, x, y):
for i in range(3):
buffer[y + i][x] = buffer[y + i][x + i] = "*"
for i in range(4):
buffer[y + 3][x + i] = "*"

print_sierpinski(2)

################################################## #############

By making the recursion explicit, I think this brings out the
self-similarity better than any of the other solutions posted,
which are very clever but not what I would call "lucid".

--
Greg
Feb 10 '07 #50

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

Similar topics

3
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...
0
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...
2
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
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...
11
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...
1
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...
1
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...
10
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>";...
47
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...
16
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.