What you are generating are usually not called "combinations" as order is not relevant in combinations, nor are duplications permitted in a combination.
Different ways of generating the desired result are described in http://www.jsoftware.com/jwiki/Essays/Odometer > As a side note - I am curious if there is a more compact way of representing > the repetitive phrase: > > (i. 6);(i. 6);(i. 6) i.&.> 6 6 6 3$<i.6 > Upon first reading, it wasn't clear to me from the definition of dyad > Antibase provided in the Vocabulary here: > > http://www.jsoftware.com/help/dictionary/d402.htm > > that its x argument could be an integer array each of whose > elements is the > desired base. The first example in the dictionary entry for the dyad #: uses an integer array left argument. ----- Original Message ----- From: Stefan Scott Alexx <stefanscottal...@gmail.com> Date: Saturday, March 13, 2010 20:33 Subject: [Jprogramming] Simpler ways to compute all combinations of x elements from a set of y elements To: programming@jsoftware.com > I just now realized that (as often seems to happen with J) there > are at > least two other ways to compute all combinations of 3 (or x) > elements from a > set of six (or y) elements. (This computation was used in my > previous post > "A viewmat phrase to display all 216 web-safe colors" to compute > argument x > to dyad viewmat.) > > So instead of the phrase provided in the previous post for > displaying 216 > web-safe colors: > > (51 * (6 (&#.)(^:_1) i. 216)) viewmat 12 18 i. 216 > > Either of the two following equivalent (possibly simpler) > phrases could also > be used, the first using "Antibase" ( #: ) and the second using > "Catalogue"or "Cartesian Product" ( } ): > > (51 * 6 6 6 #: i. 216) viewmat 12 18 $ i. 216 > > (51 * > , { (i. 6);(i. 6);(i. 6)) viewmat 12 18 $ > i. 216 > > +++ > > That previous post computed the base x representation of decimal > numberusing the dyad: > > (&#.)(^:_1) > > defined here: > > http://www.jsoftware.com/help/phrases/representations.htm > > For example, the previous post computed the base 6 > representation of the > numbers from 0 to 215 as follows: > > 6 (&#.)(^:_1) i. 216 > > However, I now see there are a couple of (possibly simpler) > alternativephrases. > > +++ > > (1) One alternative uses "Unbox" on "Enfile" on "Catalogue" or > "CartesianProduct": > > > , { (i. 6);(i. 6);(i. 6) > > "Catalog" and "Cartesian Product" are defined here: > > http://www.jsoftware.com/help/dictionary/d520.htm > > > As a side note - I am curious if there is a more compact way of > representingthe repetitive phrase: > > (i. 6);(i. 6);(i. 6) > > I have tried fiddling with tacking combinations of the adverbs ~ > and / and > ^:3 onto the verb ; ... but no luck. > > +++ > > (2) Another alternative uses "Antibase": > > 6 6 6 #: i. 216 > > defined here: > > PDF! > http://www.jsoftware.com/jwiki/HenryRich?action=AttachFile&do=get&target=J602_RefCard_color_letter_current.pdf > > +++ > > Upon first reading, it wasn't clear to me from the definition of dyad > Antibase provided in the Vocabulary here: > > http://www.jsoftware.com/help/dictionary/d402.htm > > that its x argument could be an integer array each of whose > elements is the > desired base. But the example for "Antibase" in the above PDF > from Henry > Rich made it clear how to do this. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm