Re: [Jprogramming] J v Python

2012-12-10 Thread Konrad Hinsen
--On 9 décembre 2012 18:03:04 -0500 Raul Miller  
wrote:


Have you considered writing python code to build files with regular
format?


Yes, but that's a lot of overhead, both in terms of conversion code to 
write and in terms of added steps in deployment. I believe I am better off 
doing everything in Python.


Konrad.



--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Aai


   ((+.|.)@={"0 1 ' '&,.)'abcde'
a   a
 b b
  c
 d d
e   e

On 10-12-12 03:42, km wrote:

Write verb cross.

 cross 'abcde'
  a   a
   b b
c
   d d
  e   e
  
  (Result should look like a cross with 'abcde' along both diagonals.)
  
 cross 'a'

  a
 cross 'ab'
  aa
  bb
  
Kip Murray

--
For information about J forums see http://www.jsoftware.com/forums.htm


--
Met vriendelijke groet,
@@i = Arie Groeneveld

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] J v Python

2012-12-10 Thread Boyko Bantchev
On 10 December 2012 02:10, William Tanksley, Jr  wrote:
> Every notation has problems. If you don't see them, it's not because
> they're not there. It's enormously ironic that you're denying ALL
> problems with "traditional notation"

I am perfectly aware that every notation has problems, and I have
never denied this fact, so please don't – again – put words in my
mouth.  What I (and all whom I know) don't observe at all, however,
is those problems causing any difficulties to students when they
learn algebra at school.  In fact, most of those notational problems
do not even manifest themselves in school mathematics.

> Learning an alternate system to
> help think doesn't replace learning "traditional notation". (I think
> you made this point very clearly a while ago, and I agree with you --
> there's no way to replace traditional notation in education except at
> the cost of ADDING something else.)

That's my point: no need to replace conventional notation.  But, if
using J to teach math in school is proposed, as was the case, this
*is* a replacement of a kind, or at least there would be a huge
overlapping, thus presenting an apparent source of confusion to the
kids.  I also maintain that parsing and mentally computing J
expressions is, in general, much more difficult than doing that
with conventional notation.

>> Consequently, I not only disbelieve your claims that the usual
>> algebraic notation used in school is massively problematic – I find
>> them ridiculous to the point of absurd.
>
> I didn't say anything even vaguely like that. "Massively" problematic?
> Not at all. I don't even think the notation is "problematic".

You said:

> it is not my experience that traditional algebraic notation is easy for kids
> or college students to learn.

which I understand as a statement that the notation presents a problem
by being difficult.  Then you said:

> ... I also had a hard time, as did all the people I knew growing up.
> And all the people I've ever talked to about it, including several 
> accomplished
> mathematicians.

which I understand as 'massive' (at least by universally manifesting
itself).  And this is what I disagree with.

> Now, when I read those carefully, I agree with them; your facts are
> correct. If we DID teach children to parse or to understand J's
> underlying computational model, we would indeed have a much harder
> problem.So... don't do that.

I don't see how this can be avoided.  Even using the language as a
calculator (and, incidentally, this is all what I myself am using
it for), it seems to me that some form of programming is inevitable.
Constructing expressions is already programming: isn't that a major
characteristic of APL and J?  But then the problems related to
precedence, parsing, binding scopes, etc. immediately show up.  That
parsing is dynamic (i.e. depends on the values involved) in J is a
problem serious enough in the context we are discussing.

> You're critiquing J .

To be precise, I am not criticizing J itself – I am very sceptic
about the feasibility of using it in teaching mathematics to
children.  It seems to me that those who suggest such usage severely
underestimate the difficulties involved.  And it is hardly accidental
that nobody *really* makes such use – as contrasted with making
claims about how great that would be.

> . for a
> problem that "traditional notation" can't have because it can't DO
> that stuff.

In a sense, yes, but that is not unfair.  As the expected benefits
from introducing J to school mathematics are inseparable from problems
intrinsic to software-based computing and to J in particular, they too
must be taken into account.

The concept of executable notation that we owe to Iverson is so
attractive that it is easy to not notice its drawbacks, but that does
not make them disappear.

> As a side comment -- you use the expression "very good for what it has
> been designed." Traditional notation wasn't designed.

Not in one day, by a single person and as a whole piece, of course,
but nevertheless marked by deliberateness.

>>> We're discussing your claim that J notation is inadequate
>>> compared to "traditional notation".
>> Now you are putting words in my mouth.  I didn't say that.
>
> You said almost exactly that. See the quotes above.

I said that 'traditional algebraic notation is very good for what it
has been designed, and much easier to learn for kids than parsing J …'
which I don't think is 'almost exactly' 'J notation is inadequate'.
There is no 'inadequate' in my words, which would be stronger than
I intended.  And it's important to not drop the context of school
and children, because doing so results in very different meaning.
The difference is very clear to me despite my rather poor proficiency
in English; it should be even more obvious to you as a native speaker
of the language.

> So what? I could just as easily point out that your post does the
> complementary thing, by not talking about "traditional notation" but
>

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread David Ward Lambert
   cross=: ((>: * (+. |.)@:=)@:i.@:# { ({.~ (_1-#)))
   cross ;/'abcde'
+-+-+-+-+-+
|a| | | |a|
+-+-+-+-+-+
| |b| |b| |
+-+-+-+-+-+
| | |c| | |
+-+-+-+-+-+
| |d| |d| |
+-+-+-+-+-+
|e| | | |e|
+-+-+-+-+-+
   cross 5 43 2
5  0 5
0 43 0
2  0 2

Date: Sun, 9 Dec 2012 20:42:13 -0600
From: km 
To: "programm...@jsoftware.com" 
Subject: [Jprogramming] Just for fun, verb cross
Message-ID: 

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Linda Alvord
Numbers, too!

Linda

-Original Message-
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of David Ward
Lambert
Sent: Monday, December 10, 2012 9:32 AM
To: programming
Subject: Re: [Jprogramming] Just for fun, verb cross

   cross=: ((>: * (+. |.)@:=)@:i.@:# { ({.~ (_1-#)))
   cross ;/'abcde'
+-+-+-+-+-+
|a| | | |a|
+-+-+-+-+-+
| |b| |b| |
+-+-+-+-+-+
| | |c| | |
+-+-+-+-+-+
| |d| |d| |
+-+-+-+-+-+
|e| | | |e|
+-+-+-+-+-+
   cross 5 43 2
5  0 5
0 43 0
2  0 2

Date: Sun, 9 Dec 2012 20:42:13 -0600
From: km 
To: "programm...@jsoftware.com" 
Subject: [Jprogramming] Just for fun, verb cross
Message-ID: 

--
For information about J forums see http://www.jsoftware.com/forums.htm

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] J v Python

2012-12-10 Thread Raul Miller
On Sun, Dec 9, 2012 at 5:01 PM, Boyko Bantchev  wrote:
> I also know many people who teach mathematics or informatics at
> school, at different places and certainly to students with average
> (or below) mathematical abilities.  My wife has been a school teacher
> in mathematics for years.  Neither my experience nor that of all those
> people, or that of our students shows problems with the notation.
> A person may be good at mathematics or similar subjects, or not, but
> this has nothing to do with notation.

http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=485225&url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D485225

"A small experiment in reading specifications revealed that students
already trained in discrete mathematics and the specification notation
performed very poorly; much worse than could reasonably be expected if
formal methods proponents are to be believed"


http://www.tandfonline.com/doi/abs/10.1207/s15327809jls1302_1

"Contrary to beliefs held by practitioners and researchers in
mathematics education, students were more successful solving simple
algebra story problems than solving mathematically equivalent
equations."


http://www.inference.phy.cam.ac.uk/sanjoy/benezet/clement-low.pdf

"The fact that fewer than 50 percent of these students could solve the
problems indicates the difficulty of translating into and out of
algebraic notation."


http://www.physics.umd.edu/perg/papers/redish/talks/aapt96m.htm

"Some students have trouble figuring out what are variables and what
are constants in this expression."


Also of note:

http://www.ericdigests.org/2004-3/learning.html

http://www.math.vanderbilt.edu/~schectex/commerrs/

http://www.jstor.org/discover/10.2307/27962524?uid=3739936&uid=2&uid=4&uid=3739256&sid=21101429087833

http://www.jstor.org/discover/10.2307/40248161?uid=3739936&uid=2&uid=4&uid=3739256&sid=21101429087833


> This is supported by observing that, to my best knowledge, notation
> is not among the issues raised in articles, at conferences, etc.
> where the problems of education are observed.

Hopefully my few minutes of effort here have done something to rectify
this gap in this part of your knowledge?

-- 
Raul
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Proofs in J

2012-12-10 Thread Don Guinn
Changing the thread.

No. This is a way to check one's work in deriving a proof. And it is not
too difficult to convert the tacit expression to explicit then make the
proof. See example below. Interesting that you chose a monadic test. Tacit
verb phrases are ambivalent. Therefore there must be two proofs. Actually,
the monadic form is not an identity. Easily shown by:

   ((+*-) -: (-&*:))1j1
0

It is an identity for real numbers, but not complex. It fails because
monadic + is defined as conjugate, not same.

   p=:] : +
   ((p*-) -: (-&*:))0j1+i.10
1

J is excellent as a computation tool. Doing proofs in J syntax is a bit
awkward.

Here is my proof:

proof=: 4 : 0  NB. That (+*-) -:
(-&*:)
a=.x(+*-)y
assert. a -: ((x+y)*(x-y)) NB. Definition of
fork
assert. a -: ((x*x)+(x*(-y))   +(y*x)  +(y*(-y)))  NB. * distributive
over + and -
assert. a -: ((x*x)+((x*(-y))  +(x*y)))+(y*(-y))   NB. * is commutative
assert. a -: ((x*x)+((x*(_1)*y)+(x*(1)*y)))+(y*(_1)*y) NB. Definition of
dyadic + and -
assert. a -: ((x*x)+(((_1)*x*y)+((1)*x*y)))+((_1)*y*y) NB. * is commutative
assert. a -: ((x*x)+((_1)+(1))*(x*y))  +((_1)*y*y) NB.
* distributive over + and -
assert. a -: ((x*x)+((0)*(x*y))-(y*y)) NB. Don`t remember
why
assert. a -: (x*x) -(y*y)  NB. 0 times anything
is 0
assert. a -: (x^2) -(y^2)  NB. Definition of ^
assert. a -: (*:x) -(*:y)  NB. Definition of *:
assert. a -: x(-&*:)y  NB. Definition of &
(compose)
a
)
   proof"0/~_2 _1 0 1 2 3j4
 0 3 3  0 11j_24
_3 0 0 _3  8j_24
_3 0 0 _3  8j_24
 0 3 3  0 11j_24
_11j24 _8j24 _8j24 _11j24  0

The fact that it got to the end says that each statement is correct for the
given data. Not that some other value could cause a failure, but a pretty
good way to catch errors in the proof. Gives me confidence that my proof is
valid.

Can this be done with a program? What about proofs when dealing with
defined names instead of primitives? And is there a way to do this proof
without converting tacit to explicit?

Notice that I had to set the rank of proof to zero. Not too much of a
problem in this proof, but not sure what to do if non-scalar primitives are
present.

On Sun, Dec 9, 2012 at 4:04 PM, Raul Miller  wrote:

> On Sun, Dec 9, 2012 at 4:38 PM, Don Guinn  wrote:
> > More fun to try to do it using tacit expressions. One toy I tried without
> > too much success is:
> >(+*-) -: ((-&*:)
> > I wanted to do it without using any explicit expressions.
>
> Do you mean something like this?
>((+*-) -: (-&*:)) i. 10
> 1
>
> I'm not quite clear on what you are trying to do here...
>
> Thanks,
>
> --
> Raul
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Proofs in J

2012-12-10 Thread Raul Miller
Yes... proofs are a topic that require some thought.

In J, I would usually do a proof as a sequence of statements that I
expect are all tautologies and where each sentence involves only a
minor changes from previous/next statements.

And, I would expect the reader to be verifying that they were happy
with each of the changes.  Some statements (for example, those
involving addition or subtraction of independent values in a
multiplication or division expression) require careful constraints
before they can be considered valid in a proof.

-- 
Raul

On Mon, Dec 10, 2012 at 10:57 AM, Don Guinn  wrote:
> Changing the thread.
>
> No. This is a way to check one's work in deriving a proof. And it is not
> too difficult to convert the tacit expression to explicit then make the
> proof. See example below. Interesting that you chose a monadic test. Tacit
> verb phrases are ambivalent. Therefore there must be two proofs. Actually,
> the monadic form is not an identity. Easily shown by:
>
>((+*-) -: (-&*:))1j1
> 0
>
> It is an identity for real numbers, but not complex. It fails because
> monadic + is defined as conjugate, not same.
>
>p=:] : +
>((p*-) -: (-&*:))0j1+i.10
> 1
>
> J is excellent as a computation tool. Doing proofs in J syntax is a bit
> awkward.
>
> Here is my proof:
>
> proof=: 4 : 0  NB. That (+*-) -:
> (-&*:)
> a=.x(+*-)y
> assert. a -: ((x+y)*(x-y)) NB. Definition of
> fork
> assert. a -: ((x*x)+(x*(-y))   +(y*x)  +(y*(-y)))  NB. * distributive
> over + and -
> assert. a -: ((x*x)+((x*(-y))  +(x*y)))+(y*(-y))   NB. * is commutative
> assert. a -: ((x*x)+((x*(_1)*y)+(x*(1)*y)))+(y*(_1)*y) NB. Definition of
> dyadic + and -
> assert. a -: ((x*x)+(((_1)*x*y)+((1)*x*y)))+((_1)*y*y) NB. * is commutative
> assert. a -: ((x*x)+((_1)+(1))*(x*y))  +((_1)*y*y) NB.
> * distributive over + and -
> assert. a -: ((x*x)+((0)*(x*y))-(y*y)) NB. Don`t remember
> why
> assert. a -: (x*x) -(y*y)  NB. 0 times anything
> is 0
> assert. a -: (x^2) -(y^2)  NB. Definition of ^
> assert. a -: (*:x) -(*:y)  NB. Definition of *:
> assert. a -: x(-&*:)y  NB. Definition of &
> (compose)
> a
> )
>proof"0/~_2 _1 0 1 2 3j4
>  0 3 3  0 11j_24
> _3 0 0 _3  8j_24
> _3 0 0 _3  8j_24
>  0 3 3  0 11j_24
> _11j24 _8j24 _8j24 _11j24  0
>
> The fact that it got to the end says that each statement is correct for the
> given data. Not that some other value could cause a failure, but a pretty
> good way to catch errors in the proof. Gives me confidence that my proof is
> valid.
>
> Can this be done with a program? What about proofs when dealing with
> defined names instead of primitives? And is there a way to do this proof
> without converting tacit to explicit?
>
> Notice that I had to set the rank of proof to zero. Not too much of a
> problem in this proof, but not sure what to do if non-scalar primitives are
> present.
>
> On Sun, Dec 9, 2012 at 4:04 PM, Raul Miller  wrote:
>
>> On Sun, Dec 9, 2012 at 4:38 PM, Don Guinn  wrote:
>> > More fun to try to do it using tacit expressions. One toy I tried without
>> > too much success is:
>> >(+*-) -: ((-&*:)
>> > I wanted to do it without using any explicit expressions.
>>
>> Do you mean something like this?
>>((+*-) -: (-&*:)) i. 10
>> 1
>>
>> I'm not quite clear on what you are trying to do here...
>>
>> Thanks,
>>
>> --
>> Raul
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] J v Python

2012-12-10 Thread Devon McCormick
As for using J to teach students (presumably we're talking about elementary
to high-school level), I think my exposure to APL in junior high-school
(age 13) helped me better understand matrix math concepts when they were
introduced in high-school.


On Mon, Dec 10, 2012 at 10:21 AM, Raul Miller  wrote:

> On Sun, Dec 9, 2012 at 5:01 PM, Boyko Bantchev  wrote:
> > I also know many people who teach mathematics or informatics at
> > school, at different places and certainly to students with average
> > (or below) mathematical abilities.  My wife has been a school teacher
> > in mathematics for years.  Neither my experience nor that of all those
> > people, or that of our students shows problems with the notation.
> > A person may be good at mathematics or similar subjects, or not, but
> > this has nothing to do with notation.
>
>
> http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=485225&url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D485225
>
> "A small experiment in reading specifications revealed that students
> already trained in discrete mathematics and the specification notation
> performed very poorly; much worse than could reasonably be expected if
> formal methods proponents are to be believed"
>
>
> http://www.tandfonline.com/doi/abs/10.1207/s15327809jls1302_1
>
> "Contrary to beliefs held by practitioners and researchers in
> mathematics education, students were more successful solving simple
> algebra story problems than solving mathematically equivalent
> equations."
>
>
> http://www.inference.phy.cam.ac.uk/sanjoy/benezet/clement-low.pdf
>
> "The fact that fewer than 50 percent of these students could solve the
> problems indicates the difficulty of translating into and out of
> algebraic notation."
>
>
> http://www.physics.umd.edu/perg/papers/redish/talks/aapt96m.htm
>
> "Some students have trouble figuring out what are variables and what
> are constants in this expression."
>
>
> Also of note:
>
> http://www.ericdigests.org/2004-3/learning.html
>
> http://www.math.vanderbilt.edu/~schectex/commerrs/
>
>
> http://www.jstor.org/discover/10.2307/27962524?uid=3739936&uid=2&uid=4&uid=3739256&sid=21101429087833
>
>
> http://www.jstor.org/discover/10.2307/40248161?uid=3739936&uid=2&uid=4&uid=3739256&sid=21101429087833
>
>
> > This is supported by observing that, to my best knowledge, notation
> > is not among the issues raised in articles, at conferences, etc.
> > where the problems of education are observed.
>
> Hopefully my few minutes of effort here have done something to rectify
> this gap in this part of your knowledge?
>
> --
> Raul
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Proofs in J

2012-12-10 Thread Roger Stokes

 1e308 ((+*-) -: (-&*:)) 1e308
NaN error
  1e308((+*-)-:(-&*:))1e308


- Original Message - 
From: "Don Guinn" 

To: 
Sent: Monday, December 10, 2012 3:57 PM
Subject: Re: [Jprogramming] Proofs in J



Changing the thread.

No. This is a way to check one's work in deriving a proof. And it is not
too difficult to convert the tacit expression to explicit then make the
proof. See example below. Interesting that you chose a monadic test. Tacit
verb phrases are ambivalent. Therefore there must be two proofs. Actually,
the monadic form is not an identity. Easily shown by:

  ((+*-) -: (-&*:))1j1
0

It is an identity for real numbers, but not complex. It fails because
monadic + is defined as conjugate, not same.

  p=:] : +
  ((p*-) -: (-&*:))0j1+i.10
1

J is excellent as a computation tool. Doing proofs in J syntax is a bit
awkward.

Here is my proof:

proof=: 4 : 0  NB. That (+*-) -:
(-&*:)
a=.x(+*-)y
assert. a -: ((x+y)*(x-y)) NB. Definition of
fork
assert. a -: ((x*x)+(x*(-y))   +(y*x)  +(y*(-y)))  NB. * distributive
over + and -
assert. a -: ((x*x)+((x*(-y))  +(x*y)))+(y*(-y))   NB. * is 
commutative

assert. a -: ((x*x)+((x*(_1)*y)+(x*(1)*y)))+(y*(_1)*y) NB. Definition of
dyadic + and -
assert. a -: ((x*x)+(((_1)*x*y)+((1)*x*y)))+((_1)*y*y) NB. * is 
commutative

assert. a -: ((x*x)+((_1)+(1))*(x*y))  +((_1)*y*y) NB.
* distributive over + and -
assert. a -: ((x*x)+((0)*(x*y))-(y*y)) NB. Don`t remember
why
assert. a -: (x*x) -(y*y)  NB. 0 times 
anything

is 0
assert. a -: (x^2) -(y^2)  NB. Definition of ^
assert. a -: (*:x) -(*:y)  NB. Definition of 
*:

assert. a -: x(-&*:)y  NB. Definition of &
(compose)
a
)
  proof"0/~_2 _1 0 1 2 3j4
0 3 3  0 11j_24
   _3 0 0 _3  8j_24
   _3 0 0 _3  8j_24
0 3 3  0 11j_24
_11j24 _8j24 _8j24 _11j24  0

The fact that it got to the end says that each statement is correct for 
the

given data. Not that some other value could cause a failure, but a pretty
good way to catch errors in the proof. Gives me confidence that my proof 
is

valid.

Can this be done with a program? What about proofs when dealing with
defined names instead of primitives? And is there a way to do this proof
without converting tacit to explicit?

Notice that I had to set the rank of proof to zero. Not too much of a
problem in this proof, but not sure what to do if non-scalar primitives 
are

present.

On Sun, Dec 9, 2012 at 4:04 PM, Raul Miller  wrote:


On Sun, Dec 9, 2012 at 4:38 PM, Don Guinn  wrote:
> More fun to try to do it using tacit expressions. One toy I tried 
> without

> too much success is:
>(+*-) -: ((-&*:)
> I wanted to do it without using any explicit expressions.

Do you mean something like this?
   ((+*-) -: (-&*:)) i. 10
1

I'm not quite clear on what you are trying to do here...

Thanks,

--
Raul
--
For information about J forums see http://www.jsoftware.com/forums.htm


--
For information about J forums see http://www.jsoftware.com/forums.htm




--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Proofs in J

2012-12-10 Thread David Ward Lambert
You can convert to a single dyadic proof with (the well known, I'm
ensuring)

   verb~~

> From: Don Guinn 
> To: programm...@jsoftware.com
> Subject: Re: [Jprogramming] Proofs in J
> Message-ID:
> 
> Content-Type: text/plain; charset=UTF-8
> 
> Changing the thread.
> 
> No. This is a way to check one's work in deriving a proof. And it is
> not
> too difficult to convert the tacit expression to explicit then make
> the
> proof. See example below. Interesting that you chose a monadic test.
> Tacit
> verb phrases are ambivalent. Therefore there must be two proofs.
> Actually,
> the monadic form is not an identity.


--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] J v Python

2012-12-10 Thread Edward Mokurai Cherlin
If we are going to argue J v Python, we need to at least look at NumPy
(based in part on APL) and SciPy. If anybody is interested, I can
start those topics.

I also have another set of issues, regarding choice of languages in
working with Sugar education software. I will give the background
here, and again if anybody is interested, I can provide much more
information.

Our first question is how to present programming at the elementary
school level. The options in Sugar are Turtle Art, with paths into
Logo and Python, and Etoys, with a path into Smalltalk. Both are
excellent for their purposes, and can easily be introduced in third
grade. XOs also have Perl (not recommended for children), FORTH (which
we can discuss), and GeoGebra built in. Most Sugar software is written
in Python, and we have a textbook on how to do it.

http://en.flossmanuals.net/make-your-own-sugar-activities/

Turtle Art provides a tile set implementing stack-based programming
which can be used as a path into FORTH. I am also working on math
textbooks in J, starting with first-grade arithmetic, and would like
to get J packaged for Linux generally and for Sugar in particular. I
hold with Marvin Minsky:

You don't understand anything until you learn it more than one way.

In Rebecca Herold, Managing an Information Security and Privacy
Awareness and Training Program (2005), 101.

In order to understand programming, one should have a solid grasp of
options, including both the limitations and possibilities defined by
Computer Science. In particular, one should understand the concept of
Turing Completeness, including Church's Thesis on the wide range of
methods for building Turing complete languages. I recommend at a
minimum languages on the LISP model, including Logo for children; on
the APL model, including J, used starting with first-grade arithmetic;
tile-based programming in tree structures, as in Turtle Art and Etoys;
Turing machines themselves (I built one in Turtle Art, and Alan Perlis
created a wonderful set of examples of Turing Machine extensions in
his Computer Science textbook using APL); Object-Oriented Programming,
as in Smalltalk and Etoys; and math languages such as GeoGebra. I have
also recommended Python for some purposes.

Another essential concept is called Syntactic Sugar. LISPers in
particular know that the syntax of a language is not the language.
This is in large part because LISP separates the syntax analyzer from
the rest of the language and allows users to replace it, and also
because writing a syntax analyzer in LISP is so simple and easy.

This goes with the concept of application-specific languages, which
should be easy to create. This is well understood in the LISP and
FORTH communities, but not very well elsewhere.

For practical programming, the criteria are quite different. Many
organizations prefer compatibility with past practice over any
considerations of efficiency and quality. I don't have the resources
to argue with them. My father George tried to offer the Society of
Actuaries an introductory actuarial textbook in APL, but they insisted
on FORTRAN and wouldn't even consider the possibility of providing
both.

The correct term in English for a person who speaks several languages
is "polyglot".

The correct term in English for a person who speaks only one language
is "American".

This is equally true for natural languages and computer programming languages.

-- 
Edward Mokurai (默雷/निशब्दगर्ज/نشبدگرج) Cherlin
Silent Thunder is my name, and Children are my nation.
The Cosmos is my dwelling place, the Truth my destination.
http://wiki.sugarlabs.org/go/Replacing_Textbooks
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread bob therriault
That is lovely Arie,

It is that kind of elegance that I was chasing with my rougher attempts. 

Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1  combined 
with ' '&,. means that the selection of the string becomes a choice in each row 
of displaying either the corresponding element of the string or a blank. 

Cheers, bob

On 2012-12-10, at 1:11 AM, Aai wrote:

>  ((+.|.)@={"0 1 ' '&,.)'abcde'

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Roger Hui
The expression fails if the argument has duplicate items. e.g.

   ((+.|.)@={"0 1 ' '&,.)'aabbb'
|length error
|   ((+.|.)@={"0 1' '&,.)'aabbb'



On Mon, Dec 10, 2012 at 10:18 AM, bob therriault wrote:

> That is lovely Arie,
>
> It is that kind of elegance that I was chasing with my rougher attempts.
>
> Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1
>  combined with ' '&,. means that the selection of the string becomes a
> choice in each row of displaying either the corresponding element of the
> string or a blank.
>
> Cheers, bob
>
> On 2012-12-10, at 1:11 AM, Aai wrote:
>
> >  ((+.|.)@={"0 1 ' '&,.)'abcde'
>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] J v Python

2012-12-10 Thread Raul Miller
I would be interested in NumPy.

I have to use python in some contexts, but I have not had the time to
study all the options, and on my own it would take me years to get up
to speed on something like NumPy.

As for the rest of your message: I will agree with you on the need for
a variety of perspectives on a subject, to make the subject clear.

Thanks,

-- 
Raul

On Mon, Dec 10, 2012 at 1:10 PM, Edward Mokurai Cherlin
 wrote:
> If we are going to argue J v Python, we need to at least look at NumPy
> (based in part on APL) and SciPy. If anybody is interested, I can
> start those topics.
>
> I also have another set of issues, regarding choice of languages in
> working with Sugar education software. I will give the background
> here, and again if anybody is interested, I can provide much more
> information.
>
> Our first question is how to present programming at the elementary
> school level. The options in Sugar are Turtle Art, with paths into
> Logo and Python, and Etoys, with a path into Smalltalk. Both are
> excellent for their purposes, and can easily be introduced in third
> grade. XOs also have Perl (not recommended for children), FORTH (which
> we can discuss), and GeoGebra built in. Most Sugar software is written
> in Python, and we have a textbook on how to do it.
>
> http://en.flossmanuals.net/make-your-own-sugar-activities/
>
> Turtle Art provides a tile set implementing stack-based programming
> which can be used as a path into FORTH. I am also working on math
> textbooks in J, starting with first-grade arithmetic, and would like
> to get J packaged for Linux generally and for Sugar in particular. I
> hold with Marvin Minsky:
>
> You don't understand anything until you learn it more than one way.
>
> In Rebecca Herold, Managing an Information Security and Privacy
> Awareness and Training Program (2005), 101.
>
> In order to understand programming, one should have a solid grasp of
> options, including both the limitations and possibilities defined by
> Computer Science. In particular, one should understand the concept of
> Turing Completeness, including Church's Thesis on the wide range of
> methods for building Turing complete languages. I recommend at a
> minimum languages on the LISP model, including Logo for children; on
> the APL model, including J, used starting with first-grade arithmetic;
> tile-based programming in tree structures, as in Turtle Art and Etoys;
> Turing machines themselves (I built one in Turtle Art, and Alan Perlis
> created a wonderful set of examples of Turing Machine extensions in
> his Computer Science textbook using APL); Object-Oriented Programming,
> as in Smalltalk and Etoys; and math languages such as GeoGebra. I have
> also recommended Python for some purposes.
>
> Another essential concept is called Syntactic Sugar. LISPers in
> particular know that the syntax of a language is not the language.
> This is in large part because LISP separates the syntax analyzer from
> the rest of the language and allows users to replace it, and also
> because writing a syntax analyzer in LISP is so simple and easy.
>
> This goes with the concept of application-specific languages, which
> should be easy to create. This is well understood in the LISP and
> FORTH communities, but not very well elsewhere.
>
> For practical programming, the criteria are quite different. Many
> organizations prefer compatibility with past practice over any
> considerations of efficiency and quality. I don't have the resources
> to argue with them. My father George tried to offer the Society of
> Actuaries an introductory actuarial textbook in APL, but they insisted
> on FORTRAN and wouldn't even consider the possibility of providing
> both.
>
> The correct term in English for a person who speaks several languages
> is "polyglot".
>
> The correct term in English for a person who speaks only one language
> is "American".
>
> This is equally true for natural languages and computer programming languages.
>
> --
> Edward Mokurai (默雷/निशब्दगर्ज/نشبدگرج) Cherlin
> Silent Thunder is my name, and Children are my nation.
> The Cosmos is my dwelling place, the Truth my destination.
> http://wiki.sugarlabs.org/go/Replacing_Textbooks
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Raul Miller
Here's a version that works with duplicated values (except note that
there was no specification for what the behavior should be in this
case):

   (,@(#~"0"1) (+.|.)@=)'abcde'
a   e
 b d
  c
 b d
a   e

   (,@(#~"0"1) (+.|.)@=)'abcdedcba'
a   e   a
 b d d b
  c   c
 b d d b
a   e   a

-- 
Raul

On Mon, Dec 10, 2012 at 1:21 PM, Roger Hui  wrote:
> The expression fails if the argument has duplicate items. e.g.
>
>((+.|.)@={"0 1 ' '&,.)'aabbb'
> |length error
> |   ((+.|.)@={"0 1' '&,.)'aabbb'
>
>
>
> On Mon, Dec 10, 2012 at 10:18 AM, bob therriault wrote:
>
>> That is lovely Arie,
>>
>> It is that kind of elegance that I was chasing with my rougher attempts.
>>
>> Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1
>>  combined with ' '&,. means that the selection of the string becomes a
>> choice in each row of displaying either the corresponding element of the
>> string or a blank.
>>
>> Cheers, bob
>>
>> On 2012-12-10, at 1:11 AM, Aai wrote:
>>
>> >  ((+.|.)@={"0 1 ' '&,.)'abcde'
>>
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Aai

Thanks for destroying my day.

Here's a much longer alternative

   ' ' (,{~[:((+.|.)@= ({"0 1) 0&,.) 1+i.@#@]) 'baabb'
b   b
 a a
  a
 b b
b   b

   _ (,{~ [: ((+.|.)@=({"0 1) 0&,.) 1+i.@#@]) 1 2 1 2
1 _ _ 1
_ 2 2 _
_ 1 1 _
2 _ _ 2




On 10-12-12 19:21, Roger Hui wrote:

The expression fails if the argument has duplicate items. e.g.

((+.|.)@={"0 1 ' '&,.)'aabbb'
|length error
|   ((+.|.)@={"0 1' '&,.)'aabbb'



On Mon, Dec 10, 2012 at 10:18 AM, bob therriault wrote:


That is lovely Arie,

It is that kind of elegance that I was chasing with my rougher attempts.

Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1
  combined with ' '&,. means that the selection of the string becomes a
choice in each row of displaying either the corresponding element of the
string or a blank.

Cheers, bob

On 2012-12-10, at 1:11 AM, Aai wrote:


  ((+.|.)@={"0 1 ' '&,.)'abcde'

--
For information about J forums see http://www.jsoftware.com/forums.htm


--
For information about J forums see http://www.jsoftware.com/forums.htm


--
Met vriendelijke groet,
@@i = Arie Groeneveld

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread bob therriault
Thanks Roger,

I guess this is why we race Ferrari's and go shopping in minivans. :)

My first draft survives repeats, but I still find Arie's version beautiful (and 
functional within the specs of not having repeated items).

   t0=:((>.|."1)@(*=)@:>:@i.@#){ ' ',]
   t0 'abcde'
a   a
 b b 
  c  
 d d 
e   e
   t0 'accddde'
a a
 b   b 
  b b  
   b   b   
b b
 c 
c c
   d   d   
  d d  
 d   d 
e e

With improvements suggested by Arie's version,

t1=:(+.|.)@=@i.@#{"0 1 ' '&,.
   t1 'abcde'
a   a
 b b 
  c  
 d d 
e   e
   t1 'abbbccdde'
a   a
 b b 
  b   b  
   b b   
c
   c c   
  d   d  
 d d 
e   e
   
Cheers, bob

ps. Some day I will avoid the trap of repeated items and Self Classify (monadic 
=) 
On 2012-12-10, at 10:21 AM, Roger Hui wrote:

> The expression fails if the argument has duplicate items. e.g.
> 
>   ((+.|.)@={"0 1 ' '&,.)'aabbb'
> |length error
> |   ((+.|.)@={"0 1' '&,.)'aabbb'
> 
> 
> 
> On Mon, Dec 10, 2012 at 10:18 AM, bob therriault wrote:
> 
>> That is lovely Arie,
>> 
>> It is that kind of elegance that I was chasing with my rougher attempts.
>> 
>> Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1
>> combined with ' '&,. means that the selection of the string becomes a
>> choice in each row of displaying either the corresponding element of the
>> string or a blank.
>> 
>> Cheers, bob
>> 
>> On 2012-12-10, at 1:11 AM, Aai wrote:
>> 
>>> ((+.|.)@={"0 1 ' '&,.)'abcde'
>> 
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> 
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Stefano Lanzavecchia
Ugly as hell (but my J doesn't get any better without practicing):

cross =.(((1 {. 0 # ]), ]) {~ (>:*(|.+.])@(=/~))@i.@#)
NB. Works for strings with replicated entries
cross 'aabbcdeabcde'
aa
 b  b 
  cc  
   d  d   
ee
aa
   b  b   
  cc  
 d  d 
ee
NB. Works for empty argument
$cross ''
0 0
NB. Works for scalar argument (but it generates a matrix... should
it?)
cross 'a'
a
NB. Works for numbers
cross a.i.'aabbcdeabcde'
 97   0  0  0  0   0   0  0  0  0   0  97
  0  97  0  0  0   0   0  0  0  0  97   0
  0   0 98  0  0   0   0  0  0 98   0   0
  0   0  0 98  0   0   0  0 98  0   0   0
  0   0  0  0 99   0   0 99  0  0   0   0
  0   0  0  0  0 100 100  0  0  0   0   0
  0   0  0  0  0 101 101  0  0  0   0   0
  0   0  0  0 97   0   0 97  0  0   0   0
  0   0  0 98  0   0   0  0 98  0   0   0
  0   0 99  0  0   0   0  0  0 99   0   0
  0 100  0  0  0   0   0  0  0  0 100   0
101   0  0  0  0   0   0  0  0  0   0 101
NB. Works for boxed
cross 'one';'two';'three';'four'
-T-T-T┐
│one │ │ │one │
++-+-++
││two  │two  ││
++-+-++
││three│three││
++-+-++
│four│ │ │four│
L+-+-+-


--
Stefano "WildHeart" Lanzavecchia - mailto:s...@apl.it

[ "To know oneself, one should assert oneself." ---
  Albert Camus ]

--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] J v Python

2012-12-10 Thread Boyko Bantchev
On 10 December 2012 17:21, Raul Miller  wrote:
> 
> Hopefully my few minutes of effort here have done something to rectify
> this gap in this part of your knowledge?

You would have spent your time more fruitfully – and saved mine –
had you actually read what you are posting, rather than concentrating
solely on exercising in sarcasm.

A few lines on each title.

1. Cannot read full text (behind paywall).
The freely available abstract does not say what kind of 'a small
experiment' is being commented, but even the title says that the
notation they are referring to is that of formal specifications.
Not much to do with school algebra, to say the least.  Therefore,
irrelevant.

2. Cannot read full text (behind paywall).
Probably relevant, but cannot tell without reading it.  Too much is
unknown, such as e.g. what equations and other 'representations' are
being considered, what and how is being tested, etc.  It is not clear
at all whether problems of notation as such are being discussed.

3. Discusses students' poor abilities for modelling but not notation.

4. Again, modelling abilities are the primary object of investigation.
Specifically, modelling in the domain of physics is being discussed.

I am particularly amused that you emphasize the sentence
"Some students have trouble figuring out what are variables and what
are constants in this expression."
as if it were some strong evidence of notational inadequacy.
In fact, the students simply don't know the meanings of the letters
in formulas – which letter what physical value represents – which has
nothing to do with notation.

5. Discussed are modelling-related difficulties, making connection
between formal and informal, and poor instruction.  Again, no relation
to notation as such.

6. An interesting reading overall, only a small section in which
is related to notation.  However, it turns out that even there some
errors are actually because of sloppiness and not because of flaws in
the notation itself.

7. Cannot read full text (behind paywall).
From the title and from what can be read on the first page it can
be concluded that – once more – students' modelling abilities are
studied rather than notation.

8. Not behind paywall, but requires registration.  Didn't bother.
The title, the author's language and the first page do not seem
like having anything to do with discussing notation.
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Proofs in J

2012-12-10 Thread Devon McCormick
   ((+*-) -: (-&*:))~ 10x^308
1

But mine goes to eleven:

   ((+*-) -: (-&*:))~ 11x^308
1


On Mon, Dec 10, 2012 at 12:46 PM, Roger Stokes <
r...@rogerstokes.free-online.co.uk> wrote:

>  1e308 ((+*-) -: (-&*:)) 1e308
> NaN error
>   1e308((+*-)-:(-&*:))1e308
>
>
> - Original Message - From: "Don Guinn" 
> To: 
> Sent: Monday, December 10, 2012 3:57 PM
> Subject: Re: [Jprogramming] Proofs in J
>
>
>
>  Changing the thread.
>>
>> No. This is a way to check one's work in deriving a proof. And it is not
>> too difficult to convert the tacit expression to explicit then make the
>> proof. See example below. Interesting that you chose a monadic test. Tacit
>> verb phrases are ambivalent. Therefore there must be two proofs. Actually,
>> the monadic form is not an identity. Easily shown by:
>>
>>   ((+*-) -: (-&*:))1j1
>> 0
>>
>> It is an identity for real numbers, but not complex. It fails because
>> monadic + is defined as conjugate, not same.
>>
>>   p=:] : +
>>   ((p*-) -: (-&*:))0j1+i.10
>> 1
>>
>> J is excellent as a computation tool. Doing proofs in J syntax is a bit
>> awkward.
>>
>> Here is my proof:
>>
>> proof=: 4 : 0  NB. That (+*-) -:
>> (-&*:)
>> a=.x(+*-)y
>> assert. a -: ((x+y)*(x-y)) NB. Definition of
>> fork
>> assert. a -: ((x*x)+(x*(-y))   +(y*x)  +(y*(-y)))  NB. * distributive
>> over + and -
>> assert. a -: ((x*x)+((x*(-y))  +(x*y)))+(y*(-y))   NB. * is
>> commutative
>> assert. a -: ((x*x)+((x*(_1)*y)+(x*(1)*y)))**+(y*(_1)*y) NB. Definition
>> of
>> dyadic + and -
>> assert. a -: ((x*x)+(((_1)*x*y)+((1)*x*y)))**+((_1)*y*y) NB. * is
>> commutative
>> assert. a -: ((x*x)+((_1)+(1))*(x*y))  +((_1)*y*y) NB.
>> * distributive over + and -
>> assert. a -: ((x*x)+((0)*(x*y))-(y*y)) NB. Don`t remember
>> why
>> assert. a -: (x*x) -(y*y)  NB. 0 times
>> anything
>> is 0
>> assert. a -: (x^2) -(y^2)  NB. Definition of ^
>> assert. a -: (*:x) -(*:y)  NB. Definition of
>> *:
>> assert. a -: x(-&*:)y  NB. Definition of &
>> (compose)
>> a
>> )
>>   proof"0/~_2 _1 0 1 2 3j4
>> 0 3 3  0 11j_24
>>_3 0 0 _3  8j_24
>>_3 0 0 _3  8j_24
>> 0 3 3  0 11j_24
>> _11j24 _8j24 _8j24 _11j24  0
>>
>> The fact that it got to the end says that each statement is correct for
>> the
>> given data. Not that some other value could cause a failure, but a pretty
>> good way to catch errors in the proof. Gives me confidence that my proof
>> is
>> valid.
>>
>> Can this be done with a program? What about proofs when dealing with
>> defined names instead of primitives? And is there a way to do this proof
>> without converting tacit to explicit?
>>
>> Notice that I had to set the rank of proof to zero. Not too much of a
>> problem in this proof, but not sure what to do if non-scalar primitives
>> are
>> present.
>>
>> On Sun, Dec 9, 2012 at 4:04 PM, Raul Miller 
>> wrote:
>>
>>  On Sun, Dec 9, 2012 at 4:38 PM, Don Guinn  wrote:
>>> > More fun to try to do it using tacit expressions. One toy I tried >
>>> without
>>> > too much success is:
>>> >(+*-) -: ((-&*:)
>>> > I wanted to do it without using any explicit expressions.
>>>
>>> Do you mean something like this?
>>>((+*-) -: (-&*:)) i. 10
>>> 1
>>>
>>> I'm not quite clear on what you are trying to do here...
>>>
>>> Thanks,
>>>
>>> --
>>> Raul
>>> --**--**
>>> --
>>> For information about J forums see 
>>> http://www.jsoftware.com/**forums.htm
>>>
>>>  --**--**
>> --
>> For information about J forums see 
>> http://www.jsoftware.com/**forums.htm
>>
>>
>
> --**--**--
> For information about J forums see 
> http://www.jsoftware.com/**forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Raul Miller
And, for what it's worth, here's a different plausible implementation
of cross (different only for the case of duplicated letters in the
argument when compared with the version I posted, below):

   (,@(#~"0"1) (+.|.)@=@(#\)) 'abcdedcba'

Note that replacing = with =@(#\) should also work for Aai's original version.

FYI,

-- 
Raul

On Mon, Dec 10, 2012 at 1:28 PM, Raul Miller  wrote:
> Here's a version that works with duplicated values (except note that
> there was no specification for what the behavior should be in this
> case):
>
>(,@(#~"0"1) (+.|.)@=)'abcde'
> a   e
>  b d
>   c
>  b d
> a   e
>
>(,@(#~"0"1) (+.|.)@=)'abcdedcba'
> a   e   a
>  b d d b
>   c   c
>  b d d b
> a   e   a
>
> --
> Raul
>
> On Mon, Dec 10, 2012 at 1:21 PM, Roger Hui  wrote:
>> The expression fails if the argument has duplicate items. e.g.
>>
>>((+.|.)@={"0 1 ' '&,.)'aabbb'
>> |length error
>> |   ((+.|.)@={"0 1' '&,.)'aabbb'
>>
>>
>>
>> On Mon, Dec 10, 2012 at 10:18 AM, bob therriault 
>> wrote:
>>
>>> That is lovely Arie,
>>>
>>> It is that kind of elegance that I was chasing with my rougher attempts.
>>>
>>> Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1
>>>  combined with ' '&,. means that the selection of the string becomes a
>>> choice in each row of displaying either the corresponding element of the
>>> string or a blank.
>>>
>>> Cheers, bob
>>>
>>> On 2012-12-10, at 1:11 AM, Aai wrote:
>>>
>>> >  ((+.|.)@={"0 1 ' '&,.)'abcde'
>>>
>>> --
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] J v Python

2012-12-10 Thread Bo Jacoby
Boyko, the discussion is futile whenyou do not believe that I am serious. But 
note that the expression    mc²  has the dimension of energy. The expression   
cm² (= 1cm²)   has the dimension of area. Neither of these expressions evaluate 
into a dimensionless number. 

- Bo




>
> Fra: Boyko Bantchev 
>Til: programm...@jsoftware.com 
>Sendt: 15:02 mandag den 10. december 2012
>Emne: Re: [Jprogramming] J v Python
> 
>On 10 December 2012 08:19, Bo Jacoby  wrote:
>> Boyko, congratulations! You manage to convince yourself that  cm²  is not an 
>> expression even if  mc²  is an expression. I don't follow.  3m*2m=6m². That 
>> is simple algebra where  m*m=m² . Nor do I know what you mean by 'pushing 
>> their meaning too far.'
>
>I know 'mc²' is an expression because it is present in a well-known
>formula.  Without that knowledge, I wouldn't know what it is at all.
>I also know 'cm²' is a symbol – a label denoting some unit of measure.
>Nothing in this label requires reading it as expression.
>
>I cannot believe that you are serious about not making difference
>between an expression and a label (or a name, if you prefer).
>--
>For information about J forums see http://www.jsoftware.com/forums.htm
>
>
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Raul Miller
For what it's worth, here's a parenthesis free implementation of my
two variant definitions of cross (and note that I am using what is
probably an unfamiliar J idiom here -- please feel free to ask for an
explanation, if I am not making sense):

selch=: #"0"1
orflp=: +.|.@
cross1=: ,@selch~ = orflp

cross2=: ,@selch~ =@i.@# orflp

Example use:

   cross1 'abcde'
a   e
 b d
  c
 b d
a   e
   cross2 'abcde'
a   e
 b d
  c
 b d
a   e

Here is a case where the implementation gives different results:

   cross1 'abcba'
a c a
 b b
a c a
   cross2 'abcba'
a   a
 b b
  c
 b b
a   a

FYI,

-- 
Raul

On Mon, Dec 10, 2012 at 2:48 PM, Raul Miller  wrote:
> And, for what it's worth, here's a different plausible implementation
> of cross (different only for the case of duplicated letters in the
> argument when compared with the version I posted, below):
>
>(,@(#~"0"1) (+.|.)@=@(#\)) 'abcdedcba'
>
> Note that replacing = with =@(#\) should also work for Aai's original version.
>
> FYI,
>
> --
> Raul
>
> On Mon, Dec 10, 2012 at 1:28 PM, Raul Miller  wrote:
>> Here's a version that works with duplicated values (except note that
>> there was no specification for what the behavior should be in this
>> case):
>>
>>(,@(#~"0"1) (+.|.)@=)'abcde'
>> a   e
>>  b d
>>   c
>>  b d
>> a   e
>>
>>(,@(#~"0"1) (+.|.)@=)'abcdedcba'
>> a   e   a
>>  b d d b
>>   c   c
>>  b d d b
>> a   e   a
>>
>> --
>> Raul
>>
>> On Mon, Dec 10, 2012 at 1:21 PM, Roger Hui  wrote:
>>> The expression fails if the argument has duplicate items. e.g.
>>>
>>>((+.|.)@={"0 1 ' '&,.)'aabbb'
>>> |length error
>>> |   ((+.|.)@={"0 1' '&,.)'aabbb'
>>>
>>>
>>>
>>> On Mon, Dec 10, 2012 at 10:18 AM, bob therriault 
>>> wrote:
>>>
 That is lovely Arie,

 It is that kind of elegance that I was chasing with my rougher attempts.

 Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1
  combined with ' '&,. means that the selection of the string becomes a
 choice in each row of displaying either the corresponding element of the
 string or a blank.

 Cheers, bob

 On 2012-12-10, at 1:11 AM, Aai wrote:

 >  ((+.|.)@={"0 1 ' '&,.)'abcde'

 --
 For information about J forums see http://www.jsoftware.com/forums.htm

>>> --
>>> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread km
My solution works by preparing a left argument for From { .  It has rank two 
solutions and is limited to string arguments.

cross
 ([: (+. |."1) [: (= * >:) [: i. #) { ' ' , ]
cross 'a'
 a   a
  a a 
   a  
  a a 
 a   a

Kip Murray

Sent from my iPad


On Dec 10, 2012, at 1:48 PM, Raul Miller  wrote:

> And, for what it's worth, here's a different plausible implementation
> of cross (different only for the case of duplicated letters in the
> argument when compared with the version I posted, below):
> 
>   (,@(#~"0"1) (+.|.)@=@(#\)) 'abcdedcba'
> 
> Note that replacing = with =@(#\) should also work for Aai's original version.
> 
> FYI,
> 
> -- 
> Raul
> 
> On Mon, Dec 10, 2012 at 1:28 PM, Raul Miller  wrote:
>> Here's a version that works with duplicated values (except note that
>> there was no specification for what the behavior should be in this
>> case):
>> 
>>   (,@(#~"0"1) (+.|.)@=)'abcde'
>> a   e
>> b d
>>  c
>> b d
>> a   e
>> 
>>   (,@(#~"0"1) (+.|.)@=)'abcdedcba'
>> a   e   a
>> b d d b
>>  c   c
>> b d d b
>> a   e   a
>> 
>> --
>> Raul
>> 
>> On Mon, Dec 10, 2012 at 1:21 PM, Roger Hui  wrote:
>>> The expression fails if the argument has duplicate items. e.g.
>>> 
>>>   ((+.|.)@={"0 1 ' '&,.)'aabbb'
>>> |length error
>>> |   ((+.|.)@={"0 1' '&,.)'aabbb'
>>> 
>>> 
>>> 
>>> On Mon, Dec 10, 2012 at 10:18 AM, bob therriault 
>>> wrote:
>>> 
 That is lovely Arie,
 
 It is that kind of elegance that I was chasing with my rougher attempts.
 
 Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1
 combined with ' '&,. means that the selection of the string becomes a
 choice in each row of displaying either the corresponding element of the
 string or a blank.
 
 Cheers, bob
 
 On 2012-12-10, at 1:11 AM, Aai wrote:
 
> ((+.|.)@={"0 1 ' '&,.)'abcde'
 
 --
 For information about J forums see http://www.jsoftware.com/forums.htm
 
>>> --
>>> For information about J forums see http://www.jsoftware.com/forums.htm
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread David Ward Lambert
Without looking studying the sentence evaluator, I expected

   +.|.@
(+. |.)@

to be identical to
   +.(|.@)
|.@+.


> Date: Mon, 10 Dec 2012 15:41:52 -0500
> From: Raul Miller 
> To: programm...@jsoftware.com
> Subject: Re: [Jprogramming] Just for fun, verb cross
> Message-ID:
>  +o...@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
> 
> For what it's worth, here's a parenthesis free implementation of my
> two variant definitions of cross (and note that I am using what is
> probably an unfamiliar J idiom here -- please feel free to ask for an
> explanation, if I am not making sense):
> 
> selch=: #"0"1
> orflp=: +.|.@
> cross1=: ,@selch~ = orflp
> 
> cross2=: ,@selch~ =@i.@# orflp


--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Raul Miller
Yes...

The precedence rule for conjunctions is different when no right
argument is provided.  In that case, the conjunction has lower
precedence than anything else in the language.  It's as if there's a
"free parenthesis" to its left.

In other words
   +.|.@
is equivalent to
   (+. |.)@

The reasons for this are documented in
http://www.jsoftware.com/help/dictionary/dicte.htm but this part of
the grammar does not get much use here on the forums, so it's worth a
note of explanation:

The "Conj" grammar requires a right argument, and if a right argument
is not present we use "Bident" instead.  And Bident only works when
the left edge is a part of the production, so the conjunction gets
ignored until then.

As an aside, I have not thought about why we have "0 Monad" -- why the
Bident rule is not used to handle that case.  Can anyone think of a
mechanical reason?  Or is it just emphasis?

Thanks,

-- 
Raul



On Mon, Dec 10, 2012 at 4:01 PM, David Ward Lambert
 wrote:
> Without looking studying the sentence evaluator, I expected
>
>+.|.@
> (+. |.)@
>
> to be identical to
>+.(|.@)
> |.@+.
>
>
>> Date: Mon, 10 Dec 2012 15:41:52 -0500
>> From: Raul Miller 
>> To: programm...@jsoftware.com
>> Subject: Re: [Jprogramming] Just for fun, verb cross
>> Message-ID:
>> > +o...@mail.gmail.com>
>> Content-Type: text/plain; charset=UTF-8
>>
>> For what it's worth, here's a parenthesis free implementation of my
>> two variant definitions of cross (and note that I am using what is
>> probably an unfamiliar J idiom here -- please feel free to ask for an
>> explanation, if I am not making sense):
>>
>> selch=: #"0"1
>> orflp=: +.|.@
>> cross1=: ,@selch~ = orflp
>>
>> cross2=: ,@selch~ =@i.@# orflp
>
>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


[Jprogramming] J v NumPy (was Re: J v Python)

2012-12-10 Thread Edward Mokurai Cherlin
On Mon, December 10, 2012 1:26 pm, Raul Miller wrote:
> I would be interested in NumPy.
>
> I have to use python in some contexts, but I have not had the time to
> study all the options, and on my own it would take me years to get up
> to speed on something like NumPy.

Start here.

http://docs.scipy.org/doc/
Numpy and Scipy Documentation

Welcome! This is the documentation for Numpy and Scipy .

Links to User Manual and Reference Manual.

> As for the rest of your message: I will agree with you on the need for
> a variety of perspectives on a subject, to make the subject clear.
>
> Thanks,
>
> --
> Raul
>
> On Mon, Dec 10, 2012 at 1:10 PM, Edward Mokurai Cherlin
>  wrote:
>> If we are going to argue J v Python, we need to at least look at NumPy
>> (based in part on APL) and SciPy. If anybody is interested, I can
>> start those topics.

-- 
Edward Mokurai (默雷/निशब्दगर्ज/نشبدگرج) Cherlin
Silent Thunder is my name, and Children are my nation.
The Cosmos is my dwelling place, the Truth my destination.
http://wiki.sugarlabs.org/go/Replacing_Textbooks
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] J v NumPy (was Re: J v Python)

2012-12-10 Thread Raul Miller
Gripes:

The type system seems way too complex -- why should I care in the
typical case, what type of value is used to represent the numeric
value 1?  Why can't it give me consistent operations?  For example, I
do not like that booleans do not include the value 0 and 1 -- this not
only perpetuates a mistaken understanding of George Boole's work, but
it perpetuates the type complexity.

I am also dubious about some of the comments in the documentation
about some of the features relating to "efficiency" -- given the
descriptions of some of these I am dubious that these claims are based
on benchmarks which compare the described implementation from a more
straightforward implementation.  These kinds of mechanisms have
overhead and only pay back in very specific cases.

I can live with their implementation of scalar extension (a dimension
of 1 is automatically extended to match).

I am also a bit dubious about some of the mechanisms (for example, why
does dot product sum along the second to last axis of the second
argument, rather than the first axis of the second argument?)

Anyways, these are just grumbles -- and I doubt I will ever use numpy
as a replacement for J.  Still, I might find myself translating J code
to numpy rather than regular python in some cases.

-- 
Raul

On Mon, Dec 10, 2012 at 4:51 PM, Edward Mokurai Cherlin
 wrote:
> On Mon, December 10, 2012 1:26 pm, Raul Miller wrote:
>> I would be interested in NumPy.
>>
>> I have to use python in some contexts, but I have not had the time to
>> study all the options, and on my own it would take me years to get up
>> to speed on something like NumPy.
>
> Start here.
>
> http://docs.scipy.org/doc/
> Numpy and Scipy Documentation
>
> Welcome! This is the documentation for Numpy and Scipy .
>
> Links to User Manual and Reference Manual.
>
>> As for the rest of your message: I will agree with you on the need for
>> a variety of perspectives on a subject, to make the subject clear.
>>
>> Thanks,
>>
>> --
>> Raul
>>
>> On Mon, Dec 10, 2012 at 1:10 PM, Edward Mokurai Cherlin
>>  wrote:
>>> If we are going to argue J v Python, we need to at least look at NumPy
>>> (based in part on APL) and SciPy. If anybody is interested, I can
>>> start those topics.
>
> --
> Edward Mokurai (默雷/निशब्दगर्ज/نشبدگرج) Cherlin
> Silent Thunder is my name, and Children are my nation.
> The Cosmos is my dwelling place, the Truth my destination.
> http://wiki.sugarlabs.org/go/Replacing_Textbooks
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm

[Jprogramming] convert 0,1 coding to _1,1

2012-12-10 Thread Brian Schott
Is there a better way than the verb `am` to do the 
following?


   am =:_1& (I.@:-.@]})
   am"1] 2 6 ?.@$ 2
_1 _1 _1 _1 1 _1
_1 _1 _1  1 1 _1

(B=)


--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Linda Alvord
   ((+.|.)@={"0 1 ' '&,.)'apple'
|length error
|   ((+.|.)@={"0 1' '&,.)'apple'

I think the letters must be in alphabetical order.

Linda

-Original Message-
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of bob
therriault
Sent: Monday, December 10, 2012 1:18 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Just for fun, verb cross

That is lovely Arie,

It is that kind of elegance that I was chasing with my rougher attempts. 

Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1  combined
with ' '&,. means that the selection of the string becomes a choice in each
row of displaying either the corresponding element of the string or a blank.


Cheers, bob

On 2012-12-10, at 1:11 AM, Aai wrote:

>  ((+.|.)@={"0 1 ' '&,.)'abcde'

--
For information about J forums see http://www.jsoftware.com/forums.htm

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Linda Alvord
Roger's explanation is better than mine.

Linda

-Original Message-
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda Alvord
Sent: Monday, December 10, 2012 7:41 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Just for fun, verb cross

   ((+.|.)@={"0 1 ' '&,.)'apple'
|length error
|   ((+.|.)@={"0 1' '&,.)'apple'

I think the letters must be in alphabetical order.

Linda

-Original Message-
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of bob
therriault
Sent: Monday, December 10, 2012 1:18 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Just for fun, verb cross

That is lovely Arie,

It is that kind of elegance that I was chasing with my rougher attempts. 

Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1  combined
with ' '&,. means that the selection of the string becomes a choice in each
row of displaying either the corresponding element of the string or a blank.


Cheers, bob

On 2012-12-10, at 1:11 AM, Aai wrote:

>  ((+.|.)@={"0 1 ' '&,.)'abcde'

--
For information about J forums see http://www.jsoftware.com/forums.htm

--
For information about J forums see http://www.jsoftware.com/forums.htm

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] convert 0,1 coding to _1,1

2012-12-10 Thread Peter B. Kessler

Double the distance between 0 and 1, and then shift those points left one unit 
on the number line.

  am2=: ((-&1) @ +:)
  am2"1] 2 6 ?.@$ 2 
   _1 _1 _1 _1 1 _1

   _1 _1 _1  1 1 _1

Does that make sense?

... peter

Brian Schott wrote:

Is there a better way than the verb `am` to do the following?

   am =:_1& (I.@:-.@]})
   am"1] 2 6 ?.@$ 2
_1 _1 _1 _1 1 _1
_1 _1 _1  1 1 _1

(B=)


--
For information about J forums see http://www.jsoftware.com/forums.htm

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] convert 0,1 coding to _1,1

2012-12-10 Thread David Ward Lambert
   <:@:+: 0 1
_1 1
   (_1 + +:)0 1 NB. for Linda
_1 1

> Date: Mon, 10 Dec 2012 19:13:05 -0500 (EST)
> From: Brian Schott 
> To: programm...@jsoftware.com
> Subject: [Jprogramming] convert 0,1 coding to _1,1
> Message-ID: 
> Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII
> 
> Is there a better way than the verb `am` to do the 
> following?
> 
> am =:_1& (I.@:-.@]})
> am"1] 2 6 ?.@$ 2
> _1 _1 _1 _1 1 _1
> _1 _1 _1  1 1 _1


--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] convert 0,1 coding to _1,1

2012-12-10 Thread Brian Schott
Peter and David, 
Thanks. That is a way that I had forgotten and may be preferred.

---
(B=)

On Dec 10, 2012, at 7:13 PM, Brian Schott  wrote:

> Is there a better way than the verb `am` to do the following?
> 
>   am =:_1& (I.@:-.@]})
>   am"1] 2 6 ?.@$ 2
> _1 _1 _1 _1 1 _1
> _1 _1 _1  1 1 _1
> 
> (B=)
> 
> 
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] convert 0,1 coding to _1,1

2012-12-10 Thread Linda Alvord

"My way" would even work in Algebra I.

Linda

-Original Message-
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of David Ward
Lambert
Sent: Monday, December 10, 2012 7:58 PM
To: programming
Subject: Re: [Jprogramming] convert 0,1 coding to _1,1

   <:@:+: 0 1
_1 1
   (_1 + +:)0 1 NB. for Linda
_1 1

> Date: Mon, 10 Dec 2012 19:13:05 -0500 (EST)
> From: Brian Schott 
> To: programm...@jsoftware.com
> Subject: [Jprogramming] convert 0,1 coding to _1,1
> Message-ID: 
> Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII
> 
> Is there a better way than the verb `am` to do the following?
> 
> am =:_1& (I.@:-.@]})
> am"1] 2 6 ?.@$ 2
> _1 _1 _1 _1 1 _1
> _1 _1 _1  1 1 _1


--
For information about J forums see http://www.jsoftware.com/forums.htm

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] convert 0,1 coding to _1,1

2012-12-10 Thread Roger Hui
If you really are converting random boolean values to (1,_1) values,
another possibility is _1&^ or _1^]; i.e. 0 to 1 and 1 to _1.


On Mon, Dec 10, 2012 at 8:58 PM, Brian Schott wrote:

>timespacex
> 6!:2 , 7!:2@]
>am =:_1& (I.@:-.@]})
>am2=: ((-&1) @ +:)
>amd=: <:@:+:
>aml=: _1 + +:
>d=: 2 6 5?.@$ 2
>timespacex 'am"1 d'
> 0.011278 1.05535e7
>timespacex 'am2 d'
> 0.187884 8.39091e6
>timespacex 'amd d'
> 0.004365 1.6779e7
>timespacex 'aml d'
> 0.004874 1.67789e7
>
> It looks like David's method is fastest and Peter's is most lean.
> And Linda's method loses nothing relative to David's.
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] convert 0,1 coding to _1,1

2012-12-10 Thread Roger Hui
Also {&_1 1 .


On Mon, Dec 10, 2012 at 11:32 PM, Roger Hui wrote:

> If you really are converting random boolean values to (1,_1) values,
> another possibility is _1&^ or _1^]; i.e. 0 to 1 and 1 to _1.
>
>
>
> On Mon, Dec 10, 2012 at 8:58 PM, Brian Schott wrote:
>
>>timespacex
>> 6!:2 , 7!:2@]
>>am =:_1& (I.@:-.@]})
>>am2=: ((-&1) @ +:)
>>amd=: <:@:+:
>>aml=: _1 + +:
>>d=: 2 6 5?.@$ 2
>>timespacex 'am"1 d'
>> 0.011278 1.05535e7
>>timespacex 'am2 d'
>> 0.187884 8.39091e6
>>timespacex 'amd d'
>> 0.004365 1.6779e7
>>timespacex 'aml d'
>> 0.004874 1.67789e7
>>
>> It looks like David's method is fastest and Peter's is most lean.
>> And Linda's method loses nothing relative to David's.
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] convert 0,1 coding to _1,1

2012-12-10 Thread Brian Schott
Those are fast and lean, as you can see below.


   amr=: _1&^
   timespacex 'amr d'
0.002708 8.39027e6
   amr1=: {&_1 1
   timespacex 'amr1 d'
0.002657 8.39027e6


On Tue, Dec 11, 2012 at 2:39 AM, Roger Hui  wrote:
> Also {&_1 1 .
>
>
> On Mon, Dec 10, 2012 at 11:32 PM, Roger Hui wrote:
>
>> If you really are converting random boolean values to (1,_1) values,
>> another possibility is _1&^ or _1^]; i.e. 0 to 1 and 1 to _1.
>>
>>
>>
>> On Mon, Dec 10, 2012 at 8:58 PM, Brian Schott wrote:
>>
>>>timespacex
>>> 6!:2 , 7!:2@]
>>>am =:_1& (I.@:-.@]})
>>>am2=: ((-&1) @ +:)
>>>amd=: <:@:+:
>>>aml=: _1 + +:
>>>d=: 2 6 5?.@$ 2
>>>timespacex 'am"1 d'
>>> 0.011278 1.05535e7
>>>timespacex 'am2 d'
>>> 0.187884 8.39091e6
>>>timespacex 'amd d'
>>> 0.004365 1.6779e7
>>>timespacex 'aml d'
>>> 0.004874 1.67789e7
>>>
>>> It looks like David's method is fastest and Peter's is most lean.
>>> And Linda's method loses nothing relative to David's.
>>> --
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>
>>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
(B=) <-my sig
Brian Schott
--
For information about J forums see http://www.jsoftware.com/forums.htm