maybe this is a cogent arg to hide(byte code)Boss's implementation in a
primitive(verb)?

On Tue, Jun 26, 2012 at 9:32 PM, Linda Alvord <lindaalv...@verizon.net>wrote:

> My version made it to  12!22 but very slowly.
>
> The original request in this thread was for code which did not include
> looping, so I thought my version might be interesting.
>
>    $12 comb 22
> 12 646646
>
> Linda
>
> -----Original Message-----
> From: programming-boun...@jsoftware.com
> [mailto:programming-boun...@jsoftware.com] On Behalf Of Henry Rich
> Sent: Tuesday, June 26, 2012 9:17 PM
> To: Programming forum
> Subject: Re: [Jprogramming] permutation list
>
> Take the time to ponder R. E. Boss's version (in the Wiki).  It is
> beautiful, and I have tried without success to make any improvement.
>
>    $ 12 comb 24
> 2704156 12
>
> In about 1 second.
>
> Henry Rich
>
> On 6/26/2012 8:54 PM, Linda Alvord wrote:
> > I wrote a book called "Probability in APL" many years ago.  When I
> > started to learn J I tried to rewrite my code in J.  Here is what I
> > wrote for combinations.
> >
> >     po=: [: |: ] #: [: i. */
> >     cr=:[: |: ([ = [: +/ [: po ] $ 2:) #"1 [: po ] $ 2:
> >     comb=:[: |: (! , [) $ ([: , cr) #"1 [: , ([: $ cr) $ [: i. ]
> >     $4 comb 10
> > 4 210
> >
> > It might take a little time to remember what I did.
> >
> > Linda
> >
> >
> > -----Original Message-----
> > From: programming-boun...@jsoftware.com
> > [mailto:programming-boun...@jsoftware.com] On Behalf Of bob therriault
> > Sent: Tuesday, June 26, 2012 3:02 PM
> > To: Programming forum
> > Subject: Re: [Jprogramming] permutation list
> >
> > Raul,
> >
> > I don't think that there is a 1-1 correspondence between combinations
> > and permutations, since each combination of items can have a number of
> > different permutations. In the example you give the number of items is
> > the same because the difference in the two arguments is 1, but this
> > would not be true in the general case.
> >
> > I am using the definition of combination found here:
> > http://www.mathwords.com/c/combination_formula.htm
> > and the formula for permutation found here:
> > http://www.mathwords.com/p/permutation_formula.htm
> >
> > In J the number of combinations is x!y and the number of permutations
> > is x(!@-~ * !)y, since there are !(y-x) permutations of each
> > combination. I guess that this would make the correspondence !(y-x) to 1.
> >
> > It's been a while since I sat in a combinatorics lecture, so please
> > correct me if I have this wrong, or I am using the words in a
> > different way than you.
> >
> > Cheers, bob
> >
> > On 2012-06-26, at 11:14 AM, Raul Miller wrote:
> >
> >> They are certainly different.
> >>
> >>    2 comb 3
> >> 0 1
> >> 0 2
> >> 1 2
> >>    2 perm 3
> >> 0 1 2
> >> 0 2 1
> >> 1 0 2
> >>
> >>
> >> In general, for n of m permutations and n of m combinations, the
> >> permutations are going to be longer (length m instead of length n).
> >> But the number of distinct items will be the same.
> >>
> >> --
> >> Raul
> >>
> >> On Tue, Jun 26, 2012 at 2:09 PM, Devon McCormick<devon...@gmail.com>
> > wrote:
> >>> I thought that in the usual mathematical definition, combinations
> >>> and permutations differ: for permutations, order matters; for
> >>> combinations, it does not.  Under this definition, the combinations
> >>> of
> >>> 3 things is just " i. 3 " - assuming we don't allow replacement?  If
> >>> we do allow replacement, the permutations of 3 things are given by "
> >>> {3$<i.3 " and the combinations by something like " ~./:~&.>,{3$<i.3 ".
> >>>
> >>> Does this seem right?
> >>>
> >>> On Tue, Jun 26, 2012 at 12:51 PM, Raul Miller<rauldmil...@gmail.com>
> > wrote:
> >>>> Note that the number of combinations and the number of permutions
> >>>> are
> > the same.
> >>>>
> >>>> And, perm is just: ! A.&i. ]
> >>>>
> >>>> It seems like there ought to be a way of putting the permutations
> >>>> in
> >>>> 1 to 1 correspondence with the combinations (to give us a concise
> >>>> expression for combinations).
> >>>>
> >>>> --
> >>>> Raul
> >>>>
> >>>> On Tue, Jun 26, 2012 at 12:41 PM, ed bierly<ebie...@gmail.com>
>  wrote:
> >>>>> yes combinations not permutations
> >>>>> thought there might be a way that didn't loop thank you for the
> >>>>> references
> >>>>>
> >>>>> On Tue, Jun 26, 2012 at 12:30 PM, R.E. Boss<r.e.b...@planet.nl>
> wrote:
> >>>>>
> >>>>>> 4 comb 10
> >>>>>>
> >>>>>>
> >>>>>> R.E. Boss
> >>>>>>
> >>>>>>
> >>>>>>> -----Oorspronkelijk bericht-----
> >>>>>>> Van: programming-boun...@jsoftware.com [mailto:
> >>>>>> programming-boun...@jsoftware.com] Namens ed bierly
> >>>>>>> Verzonden: dinsdag 26 juni 2012 18:15
> >>>>>>> Aan: programming@jsoftware.com
> >>>>>>> Onderwerp: [Jprogramming] permutation list
> >>>>>>>
> >>>>>>> what is the best way to get this list of 210 vectors?
> >>>>>>>
> >>>>>>> 4!10
> >>>>>>> ----------------------------------------------------------------
> >>>>>>> -
> >>>>>>> ----- For information about J forums see
> >>>>>>> http://www.jsoftware.com/forums.htm
> >>>>>>
> >>>>>> -----------------------------------------------------------------
> >>>>>> -
> >>>>>> ---- For information about J forums see
> >>>>>> http://www.jsoftware.com/forums.htm
> >>>>>>
> >>>>> ------------------------------------------------------------------
> >>>>> -
> >>>>> --- For information about J forums see
> >>>>> http://www.jsoftware.com/forums.htm
> >>>> -------------------------------------------------------------------
> >>>> -
> >>>> -- For information about J forums see
> >>>> http://www.jsoftware.com/forums.htm
> >>>
> >>>
> >>>
> >>> --
> >>> Devon McCormick, CFA
> >>> ^me^ at acm.
> >>> org is my
> >>> preferred e-mail
> >>> --------------------------------------------------------------------
> >>> -
> >>> - For information about J forums see
> >>> http://www.jsoftware.com/forums.htm
> >> ---------------------------------------------------------------------
> >> - For information about J forums see
> >> http://www.jsoftware.com/forums.htm
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to