,/>{x
Henry Rich
On 12/20/2020 1:48 PM, Skip Cave wrote:
I have three lists stored in x:
]x=.1 3 5;2;3 4
┌─────┬─┬───┐
│1 3 5│2│3 4│
└─────┴─┴───┘
I want to find all possible combinations of the elements of these lists
(taking one from each list).
Using the odometer function I can generate all the possible index
combinations of selections from those three lists:
odo ;# each x
0 0 0
0 0 1
1 0 0
1 0 1
2 0 0
2 0 1
Now I can individually find each selection from the three lists
;0 0 0{ea { >x
1 2 3
;0 0 1{ea { >x
1 2 4
;1 0 0{ea { >x
3 2 3
;1 0 1{ea { >x
3 2 4
;2 0 0{ea { >x
5 2 3
;2 0 1{ea { >x
5 2 4
How can I generate all of the selections in one 6x3 matrix using just one
statement, with no explicit looping?
Skip
Skip Cave
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by AVG.
https://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm