I think your difficulty might be in not recognising that the length of the combination vector, or the order of the tuple, representing the combination is a property of the input: Norman's expression for a combination (c0, c1, c2...,c(r-1)) of r out
of n integers,  where c(i) e. i.n  ,  (AND c(i) < c(i+1) ),
is C(c0,1) + C(c1,2) + ... + C(c(r-1),r)

It turns out that (i.r!n) -: /:~ ctoi"1 r comb n, ie the r-combinations of n integers
map onto the integers from 0 to <: r!n .

So you would expect that ctoi on an r-combination from m is also the ctoi on an
s-combination from n,  if r!m < s!n,   eg
   /:~ctoi"1 ]3 comb 6
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
   /:~ctoi"1 ]2 comb 7
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

As parenthetised above,  the combinations do need to be ordered.

Norman goes on to discuss the inverse verb "itoc", which needs to be dyadic,
recognising that it needs to know "r" ,

Also,  your first four combinations all begin in 1,  while combinations as discussed in J include zero, so that first example consists of 3 perms of 4 from 5, and 1 perm of 3 from 4.  However, the second example, 0 1 2; 0 1 2 3 shows the singleton sets of all 3x3 and 4x4 combinations respectively, both properly having a ctoi of 0 .

Cheers,

Mike

On 11/12/2018 17:09, Devon McCormick wrote:
In chapter 34 of "50 Shades", I'm questioning the assertion "any
combination of r integers from i.n can be put into one-to-one
correspondence with the counting integers " because this seems to
contradict these tests:
    ctoi=: 3 : '+/(>:i.#y)!y'  NB. combination to integer
    ctoi&>3 2 1 4;4 3 2 1;1 2 3 4;3 2 1
5 7 4 4
The first three permutations of the same combination map to different
numbers but the last two different combos map to the same number.
Am I misinterpreting the assertion?  Or does the combination need to be
sorted?
    (ctoi@:/:~) &> 3 2 1 4;4 3 2 1;1 2 3 4;3 2 1  NB. OK
4 4 4 3
but
    (ctoi@:/:~) &> 0 1 2;0 1 2 3
0 0



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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

Reply via email to