Stumbled the other day on 

 

   ([: +/\&.:>: #&0) 5

0 1 2 3 4

 

So ([: +/\&.:>: #&0) is equivalent with i. for non-negative integers and
therefore a candidate for Bron's
http://www.jsoftware.com/jwiki/PrimitivePrimitives .

 

Modifying it a bit you get

 

   ($ [: +/\&.:>: 0 #~ */) 2 3

0 1 2

3 4 5

 

and the equivalence is enlarged to non-negative vectors.

 

 

Some observations.

 

1. 

I started with [: +/\&.(1&+) #&0  and changed it to [: +/\&.>: #&0 , however

 

   ([: +/\&.>: #&0) 3

0

0

0

 

due to rank >: being 0, so that was solved by

 

   ([: +/\&.:>: #&0) 3

0 1 2

 

 

2.

Well known is

 

   +/\ b. _1

(- |.!.0) :.(+/\)

 

Strange however is

 

   +/\&.(1&+) b. _1

(- |.!.0) :.(+/\)&.(1&+)

 

since I expected that if f=. g^:_1 then g&.h^:_1 would be f&.h .

And obviously it does not work:

 

   (- |.!.0) +/\&.(1&+) 5 # 0

0 1 1 1 1

 

But this does work as expected:

 

   (- |.!.0)&.(1&+) +/\&.(1&+) 5#0

0 0 0 0 0

 

And so does this, remarkably enough: 

 

    +/\&.(1&+)^:_1 +/\&.(1&+) 5#0

0 0 0 0 0

 

 

3.

On the other hand you get:

 

   +/\&.:>: b. _1

|domain error

|       +/\&.:>:b._1

 

consequently followed by:

 

   +/\&.:>:^:_1 +/\&.:>: 5 # 0

|domain error

|       +/\&.:>:^:_1+/\&.:>:5#0

 

 

4.

   rank'([: +/\&.:>: #&0) t';'i.t'[t=:1e5

+----+-----+----+----+

|rank|tm*sz|time|size|

+----+-----+----+----+

| 1  |8.43 |3.96|2.13|

+----+-----+----+----+

| 0  |1.00 |1.00|1.00|

+----+-----+----+----+

 

proves i. is still far more efficient.

 

 

R.E. Boss

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

Reply via email to