RE: math combinations
- Posted by Henri.Goffin at sbs.be May 27, 2002
- 422 views
There is a little weakness in the Permutation function in R. Forno's Genfunc.e. It does not correctly manage a sequence that contains sequences as elements. You can convince yourself with the following: ------------------------------------------ include genfunc.e sequence S S = {{1},2,{3,4}} for i = 1 to 6 do -- 6 = 3! (factorial, the number of permutations of 3 objects) ?Permutation(S,length(S),i) end for ---------------------------------------- But the correction seems straightforward. In genfunc.e (version 1.3) on line 2072, replace: return set[a] & Permutation(set[1..a-1] & set[a+1..len], size - 1, which) with: return {set[a]} & Permutation(set[1..a-1] & set[a+1..len], size - 1, which) Have a nice day, all. Henri Goffin > -----Original Message----- > From: tone.skoda at siol.net [SMTP:tone.skoda at siol.net] > Sent: 27 May, 2002 05:49 > To: EUforum > Subject: Re: math combinations > > > I figured it out now after I searched mailing list archives. > > for i = 1 to 10 do > ? Permutation({1, 2, 3}, 3, i) > end for > > Still an example for every function would be very nice. > > ----- Original Message ----- > From: <tone.skoda at siol.net> > To: "EUforum" <EUforum at topica.com> > Sent: Monday, May 27, 2002 5:01 AM > Subject: Re: math combinations > > > > > > Thanks, but I really don't know how to use that function. > > It would help if it had examples cause with examples you can see > the > > most clear what something does. > > > > Here it is with all its documentation: > > > > Permutation(sequence set, integer size, integer which) > > --Returns a sequence containing the permutation with size 'size', > > -- numbered 'which', from the set 'set'. > > --The set is any sequence of objects, and so is the result. > > --'which' starts at 1 and goes to the number of existing permutations > > -- of this size. > > --In case 'which' is out of bounds, an atom containing -1 is returned. > > > > ----- Original Message ----- > > From: "Derek Parnell" <Derek.Parnell at SYD.RABOBANK.COM> > > To: "EUforum" <EUforum at topica.com> > > Sent: Monday, May 27, 2002 4:13 AM > > Subject: RE: math combinations > > > > > > > > > > Have a look at Ricardo Forno's general utility package in th > contributions > > > page. It has a Permutations function in it which sounds like it might > work > > > for you. > > > > > > is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht > > > onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en > > > de afzender direct te informeren door het bericht te retourneren. > > > and is intended to be exclusively for the addressee. Should you > > > receive this message unintentionally, please do not use the contents > > > herein and notify the sender immediately by return e-mail. > > > > > > > > > > >