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

-- 

Devon McCormick, CFA

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

Reply via email to