I propose altering the verb perm in statfns.ijs (and
elsewhere, if perm exists elsewhere) with the following so
that perm is ambivalent and the dyadic form is syntactically
like comb. It may also be time to replace comb with cmb but
I am less clear on this replacement.
chs=: 4 : ';(,/@:(([,. ]+ <:)"0 _) )&.>/ (<i.1 0),~ i.&.>x{.(-i.)y'
perm=: (! A.&i. ]) : chs
On Sun, 10 Aug 2008, R.E. Boss wrote:
+ Define a
+ (k,n)-choice to be an ordered subset of k elements from a set of n
+ elements and a
+ (k,n)-combination to be an unordered subset of k elements from a set of n
+ elements,
+ than the question (see (*0) below) naturally arises:
+ What is the index of a (k,n)-combination in the lexicographically ordered
+ set of (k,n)-choices?
+
+ Let cmb generates all (k,n)-combinations (see also (*1) below):
+ cmb=: [:,.^:(2>[EMAIL PROTECTED])@; [:(,.&.><@;\.)/ >:@[EMAIL PROTECTED]
+
+ and chs all (k,n)-choices, see
+ http://www.jsoftware.com/pipermail/programming/2008-August/011683.html
+ chs=: 4 : ';(,/@:(([,. ]+ <:)"0 _) )&.>/ (<i.1 0),~ i.&.>x{.(-i.)y'
+
+ Example:
+
+ |:2 chs 5 NB. (2,5)-choices in columns
+ 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
+ 1 2 3 4 0 2 3 4 0 1 3 4 0 1 2 4 0 1 2 3
+
+ |:2 cmb 5 NB. (2,5)-combinations in columns
+ 0 0 0 0 1 1 1 2 2 3
+ 1 2 3 4 2 3 4 3 4 4
+
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm