(1 2 3 4 perm each 4) { each <1 3 5 7 Untested. Or,
1 2&p.&.> 1 2 3 4 perm each 4 Also untested. Henry Rich On 12/5/2018 8:45 PM, Skip Cave wrote:
I want to generate all the 1, 2, 3, & 4 permutations of 4 items. I can generate the indices: (1 2 3 4 perm each 4) ┌─┬───┬─────┬───────┐ │0│0 1│0 1 2│0 1 2 3│ │1│1 0│0 2 1│0 1 3 2│ │2│0 2│1 0 2│0 2 1 3│ │3│2 0│1 2 0│0 2 3 1│ │ │0 3│2 0 1│0 3 1 2│ │ │3 0│2 1 0│0 3 2 1│ │ │1 2│0 1 3│1 0 2 3│ │ │2 1│0 3 1│1 0 3 2│ │ │1 3│1 0 3│1 2 0 3│ │ │3 1│1 3 0│1 2 3 0│ │ │2 3│3 0 1│1 3 0 2│ │ │3 2│3 1 0│1 3 2 0│ │ │ │0 2 3│2 0 1 3│ │ │ │0 3 2│2 0 3 1│ │ │ │2 0 3│2 1 0 3│ │ │ │2 3 0│2 1 3 0│ │ │ │3 0 2│2 3 0 1│ │ │ │3 2 0│2 3 1 0│ │ │ │1 2 3│3 0 1 2│ │ │ │1 3 2│3 0 2 1│ │ │ │2 1 3│3 1 0 2│ │ │ │2 3 1│3 1 2 0│ │ │ │3 1 2│3 2 0 1│ │ │ │3 2 1│3 2 1 0│ └─┴───┴─────┴───────┘ How can I apply those indices to a 4-element vector consisting of the integers 1 3 5 7, in order to generate all the 1, 2, 3, & 4 permutations of those 4 integers? (1 2 3 4 perm each 4) each {1 3 5 7 |domain error: each | (1 2 3 4 perm each 4) each{1 3 5 7 Fail! Skip ---------------------------------------------------------------------- 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