Roman
Roman

Reputation: 1498

Why "0 not equivalent to "_1 when arguments are one dimensional arrays?

Why these two expression not equivalent in this situation?

   0 1 2 ,"(0)/ 0 1
0 0
0 1

1 0
1 1

2 0
2 1

   0 1 2 ,"(_1)/ 0 1
|length error
|   0 1 2    ,"(_1)/0 1

Actually what I'm trying to do...

a =: 0 1 2 3 4 5 ; 0 1 2 ; 0 1

Want to get all possible combinations

,"0/&>/ a

This code doesn't work
This works though:

0 1 2 3 4 5 ,"(0 1)/ 0 1 2 ,"(0 0)/ 0 1

But, of course, I want to write in short form

,"0/&>/ a

The problem is that all terms should be

,"(0 1)/

but last

,"(0 0)/

Upvotes: 1

Views: 74

Answers (2)

rdm
rdm

Reputation: 688

"_1 is equivalent to "0"_

In other words, "_1 forms a verb which looks at all the data to find its rank and then derives another verb to work at one rank lower than that.

Upvotes: 0

bob
bob

Reputation: 4302

Maybe this will help, as what it doing is simply appending at a rank of 0

    0  ,"(0)/ 0 1
0 0
0 1
      1  ,"(0)/ 0 1
1 0
1 1
      2  ,"(0)/ 0 1
2 0
2 1

For the actual solution to the problem you are investigating, have you looked at Catalogue? {

   {a
┌─────┬─────┐
│0 0 0│0 0 1│
├─────┼─────┤
│0 1 0│0 1 1│
├─────┼─────┤
│0 2 0│0 2 1│
└─────┴─────┘

┌─────┬─────┐
│1 0 0│1 0 1│
├─────┼─────┤
│1 1 0│1 1 1│
├─────┼─────┤
│1 2 0│1 2 1│
└─────┴─────┘

┌─────┬─────┐
│2 0 0│2 0 1│
├─────┼─────┤
│2 1 0│2 1 1│
├─────┼─────┤
│2 2 0│2 2 1│
└─────┴─────┘

┌─────┬─────┐
│3 0 0│3 0 1│
├─────┼─────┤
│3 1 0│3 1 1│
├─────┼─────┤
│3 2 0│3 2 1│
└─────┴─────┘

┌─────┬─────┐
│4 0 0│4 0 1│
├─────┼─────┤
│4 1 0│4 1 1│
├─────┼─────┤
│4 2 0│4 2 1│
└─────┴─────┘

┌─────┬─────┐
│5 0 0│5 0 1│
├─────┼─────┤
│5 1 0│5 1 1│
├─────┼─────┤
│5 2 0│5 2 1│
└─────┴─────┘

Catalogue matches the Append Table:

  (>{a)-: 0 1 2 3 4 5 ,"(0 1)/ 0 1 2 ,"(0 0)/ 0 1
1

Upvotes: 1

Related Questions