1. math combinations

This is a multi-part message in MIME format.

------=_NextPart_000_001C_01C20532.A5A9D670
	charset="iso-8859-2"

How would I write a routine which would shuffle all members in a =
sequence so that all possible combinations would be gotten?
Also, input sequence could have two or more equal members.

For example, all combinations for {'a','b','c'} would be:
{'a','b','c'}
{'a','c','b'}
{'b','a','c'}
{'b','c','a'}
{'c','b','a'}



------=_NextPart_000_001C_01C20532.A5A9D670
Content-Type: text/html;
	charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-2">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>How would I write a routine which would =
shuffle all=20
members in a sequence so that&nbsp;all possible combinations would be=20
gotten?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Also, input sequence could have two or =
more equal=20
members.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>For example, all combinations for =
{'a','b','c'}=20
would=20
be:<BR>{'a','b','c'}<BR>{'a','c','b'}<BR>{'b','a','c'}<BR>{'b','c','a'}<B=
R>{'c','b','a'}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>

------=_NextPart_000_001C_01C20532.A5A9D670--

new topic     » topic index » view message » categorize

2. Re: math combinations

On 27 May 2002, at 3:57, tone.skoda at siol.net wrote:

> 
> How would I write a routine which would shuffle all members in a sequence so
> that all possible combinations would be gotten? Also, input sequence could
> have
> two or more equal members.
> 
> For example, all combinations for {'a','b','c'} would be:
> {'a','b','c'}
> {'a','c','b'}
> {'b','a','c'}
> {'b','c','a'}
> {'c','b','a'}

I think it was Jiri who wrote a mesh.e, it's in the archives somewhere.

Kat

new topic     » goto parent     » topic index » view message » categorize

3. 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.
>
> ==================================================================
> De informatie opgenomen in dit bericht kan vertrouwelijk zijn en
> 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.
> ==================================================================
> The information contained in this message may be confidential
> 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.
>
>
> ==================================================================
>
>
>
>

new topic     » goto parent     » topic index » view message » categorize

4. 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>
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.
> >
> >
> >
>
>
>

new topic     » goto parent     » topic index » view message » categorize

5. Re: math combinations

Thanks! You saved me a lot of trouble, I was going to use it for sequences.

----- Original Message -----
From: <Henri.Goffin at sbs.be>
To: "EUforum" <EUforum at topica.com>
Subject: RE: math combinations


>
> 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.
> > > >
> > > >
> > > >
>
>
>

new topic     » goto parent     » topic index » view message » categorize

6. Re: math combinations

Thanks, Derek!
I usually can't answer mails immediately, because I connect to the Web at
about 22:00 Buenos Aires time, and remain connected only for a few minutes.
So, when I read a mail I can answer, some one else has already answered
it...
Regards.
PS. The Permutations function is just what Tone asked for.
----- Original Message -----
From: "Derek Parnell" <Derek.Parnell at SYD.RABOBANK.COM>
To: "EUforum" <EUforum at topica.com>
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.
>
> ==================================================================
>
>
> ==================================================================
>
>
>
>

new topic     » goto parent     » topic index » view message » categorize

7. Re: math combinations

Well, I thought the explanation was crystal clear...;)
In a future version, I will add examples.
Anyway, it works not only for set = {1, 2, 3}, size = 3, which = 1 to
factorial(3), but also setting size = 2, for example. In such a case, in
each permutation one (or more) of the elements will miss.
----- Original Message -----
From: <tone.skoda at siol.net>
To: "EUforum" <EUforum at topica.com>
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.
> > >
> > >
> > >
>
>
>

new topic     » goto parent     » topic index » view message » categorize

8. Re: math combinations

Thanks for the correction, Henri!
----- Original Message -----
From: <Henri.Goffin at sbs.be>
To: "EUforum" <EUforum at topica.com>
Subject: RE: math combinations


>
> 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.
> > > >
> > > >
> > > >
>
>
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu