<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Listing strings of length n composed of k given elements</title>
    <link>http://www.mapleprimes.com/questions/42467-Listing-Strings-Of-Length-N-Composed</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Fri, 12 Jun 2026 23:59:37 GMT</lastBuildDate>
    <pubDate>Fri, 12 Jun 2026 23:59:37 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Listing strings of length n composed of k given elements</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Listing strings of length n composed of k given elements</title>
      <link>http://www.mapleprimes.com/questions/42467-Listing-Strings-Of-Length-N-Composed</link>
    </image>
    <item>
      <title>combinat[permute]</title>
      <link>http://www.mapleprimes.com/questions/42467-Listing-Strings-Of-Length-N-Composed?ref=Feed:MaplePrimes:Listing strings of length n composed of k given elements:Comments#answer79466</link>
      <itunes:summary>Emrah,

You should look at the permute command in the combinat package. Here is a possible solution to your request:

&lt;pre&gt;
P := ( n::integer, symbols::list )
      -&gt; combinat[permute]( [seq( s$n, s=symbols )], n );
&lt;/pre&gt;

Then, your example would be produced with:
&lt;pre&gt;
P( 3, [0,1] );
&lt;/pre&gt;

You could also do something like
&lt;pre&gt;
P( 5, [heads,tails] );
&lt;/pre&gt;

The only real "trick" in this solution is creating the list of symbols with n copies of each symbol. This is what is done with the seq command above.

If you want to use the permute command elsewhere in a worksheet I recommend loading the combinat package by issuing the command
&lt;pre&gt;
with( combinat );
&lt;/pre&gt;
Then you can refer to permute without explicit reference to combinat[permute].

I hope this is useful.

Doug
&lt;pre&gt;
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
&lt;\pre&gt;</itunes:summary>
      <description>Emrah,

You should look at the permute command in the combinat package. Here is a possible solution to your request:

&lt;pre&gt;
P := ( n::integer, symbols::list )
      -&gt; combinat[permute]( [seq( s$n, s=symbols )], n );
&lt;/pre&gt;

Then, your example would be produced with:
&lt;pre&gt;
P( 3, [0,1] );
&lt;/pre&gt;

You could also do something like
&lt;pre&gt;
P( 5, [heads,tails] );
&lt;/pre&gt;

The only real "trick" in this solution is creating the list of symbols with n copies of each symbol. This is what is done with the seq command above.

If you want to use the permute command elsewhere in a worksheet I recommend loading the combinat package by issuing the command
&lt;pre&gt;
with( combinat );
&lt;/pre&gt;
Then you can refer to permute without explicit reference to combinat[permute].

I hope this is useful.

Doug
&lt;pre&gt;
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
&lt;\pre&gt;</description>
      <guid>79466</guid>
      <pubDate>Fri, 06 Oct 2006 17:00:25 Z</pubDate>
      <itunes:author>Doug Meade</itunes:author>
      <author>Doug Meade</author>
    </item>
    <item>
      <title>Thanks it really worked :-)
</title>
      <link>http://www.mapleprimes.com/questions/42467-Listing-Strings-Of-Length-N-Composed?ref=Feed:MaplePrimes:Listing strings of length n composed of k given elements:Comments#answer79465</link>
      <itunes:summary>Thanks it really worked :-)</itunes:summary>
      <description>Thanks it really worked :-)</description>
      <guid>79465</guid>
      <pubDate>Fri, 06 Oct 2006 17:07:04 Z</pubDate>
      <itunes:author>Emrah
 Akyar
</itunes:author>
      <author>Emrah
 Akyar
</author>
    </item>
    <item>
      <title>Generate strings</title>
      <link>http://www.mapleprimes.com/questions/42467-Listing-Strings-Of-Length-N-Composed?ref=Feed:MaplePrimes:Listing strings of length n composed of k given elements:Comments#answer79360</link>
      <itunes:summary>Also, StringTools package has Generate command that does exactly what you want (if you want strings), &lt;pre&gt;s:=StringTools:-Generate(3,"01");

    s := ["000", "001", "010", "011", "100", "101", "110", "111"]

printf("%s",&amp;lt;s[]&amp;gt;);

000
001
010
011
100
101
110
111&lt;/pre&gt;
</itunes:summary>
      <description>Also, StringTools package has Generate command that does exactly what you want (if you want strings), &lt;pre&gt;s:=StringTools:-Generate(3,"01");

    s := ["000", "001", "010", "011", "100", "101", "110", "111"]

printf("%s",&amp;lt;s[]&amp;gt;);

000
001
010
011
100
101
110
111&lt;/pre&gt;
</description>
      <guid>79360</guid>
      <pubDate>Tue, 17 Oct 2006 13:30:43 Z</pubDate>
      <itunes:author>alec</itunes:author>
      <author>alec</author>
    </item>
    <item>
      <title>une methode possible</title>
      <link>http://www.mapleprimes.com/questions/42467-Listing-Strings-Of-Length-N-Composed?ref=Feed:MaplePrimes:Listing strings of length n composed of k given elements:Comments#answer76655</link>
      <itunes:summary>bonjour,
j'ai crée la procédure frtot:

frtot:=proc(s,n);l:=[seq([s[i]],i=1..nops(s))];for ki from 1 to n do l:=[seq(seq([op(l[i]),s[j]],j=1..nops(s)),i=1..nops(l))];if s[1]::list then [seq(matrix(l[k]),k=1..nops(l))] else l fi;od;end;

n représente le nombre d'éléments k-1
par exemple on fait frtot([1,0],2);
on obtient   [[1, 1, 1], [1, 1, 0], [1, 0, 1], [1, 0, 0], [0, 1, 1], [0, 1, 0], [0, 0, 1], [0, 0, 0]]
</itunes:summary>
      <description>bonjour,
j'ai crée la procédure frtot:

frtot:=proc(s,n);l:=[seq([s[i]],i=1..nops(s))];for ki from 1 to n do l:=[seq(seq([op(l[i]),s[j]],j=1..nops(s)),i=1..nops(l))];if s[1]::list then [seq(matrix(l[k]),k=1..nops(l))] else l fi;od;end;

n représente le nombre d'éléments k-1
par exemple on fait frtot([1,0],2);
on obtient   [[1, 1, 1], [1, 1, 0], [1, 0, 1], [1, 0, 0], [0, 1, 1], [0, 1, 0], [0, 0, 1], [0, 0, 0]]
</description>
      <guid>76655</guid>
      <pubDate>Fri, 22 Jun 2007 14:15:20 Z</pubDate>
      <itunes:author>xavier</itunes:author>
      <author>xavier</author>
    </item>
    <item>
      <title>language</title>
      <link>http://www.mapleprimes.com/questions/42467-Listing-Strings-Of-Length-N-Composed?ref=Feed:MaplePrimes:Listing strings of length n composed of k given elements:Comments#comment85397</link>
      <itunes:summary>인천 남구 용현동에 위치한 4년제 사립대학으로써, 1954년 인하공과대학으로 설립되어, 현재 공과대학·자연과학대학·경상대학·경영대학·사범대학·법과대학·사회과학

If postings are accepted in French, then how about other languages, such as Korean?

My point is that it is not feasible for MaplePrimes readers to know the native languages of all Maple users.  The only natural language that MaplePrimes readers can be assumed to know is English.

Note 1: English is the language of international scientific discourse (I did not choose this, and would not have chosen English if I had the choice).

Note 2: I have no idea what the Korean quote says.</itunes:summary>
      <description>인천 남구 용현동에 위치한 4년제 사립대학으로써, 1954년 인하공과대학으로 설립되어, 현재 공과대학·자연과학대학·경상대학·경영대학·사범대학·법과대학·사회과학

If postings are accepted in French, then how about other languages, such as Korean?

My point is that it is not feasible for MaplePrimes readers to know the native languages of all Maple users.  The only natural language that MaplePrimes readers can be assumed to know is English.

Note 1: English is the language of international scientific discourse (I did not choose this, and would not have chosen English if I had the choice).

Note 2: I have no idea what the Korean quote says.</description>
      <guid>85397</guid>
      <pubDate>Fri, 22 Jun 2007 20:53:15 Z</pubDate>
      <itunes:author>DJKeenan</itunes:author>
      <author>DJKeenan</author>
    </item>
    <item>
      <title>other languages</title>
      <link>http://www.mapleprimes.com/questions/42467-Listing-Strings-Of-Length-N-Composed?ref=Feed:MaplePrimes:Listing strings of length n composed of k given elements:Comments#comment91557</link>
      <itunes:summary>I don't see the problem with people posting in other languages.  It wouldn't be bad for MaplePrimes to attract a wider audience.  Of course if you are posting a reply and you expect the person to understand it then it's probably best to use their language, but plenty of people can read French even if they would prefer not to look like an idiot trying to write it and there are lots of Japanese users of Maple too.  If I'm really interested in what someone could be saying there are lots of automatic translation tools such as &lt;a href="http://babelfish.altavista.com"&gt;BabelFish&lt;/a&gt;.  I would prefer not to exclude people who don't speak English, or don't speak it well enough to feel comfortable posting.</itunes:summary>
      <description>I don't see the problem with people posting in other languages.  It wouldn't be bad for MaplePrimes to attract a wider audience.  Of course if you are posting a reply and you expect the person to understand it then it's probably best to use their language, but plenty of people can read French even if they would prefer not to look like an idiot trying to write it and there are lots of Japanese users of Maple too.  If I'm really interested in what someone could be saying there are lots of automatic translation tools such as &lt;a href="http://babelfish.altavista.com"&gt;BabelFish&lt;/a&gt;.  I would prefer not to exclude people who don't speak English, or don't speak it well enough to feel comfortable posting.</description>
      <guid>91557</guid>
      <pubDate>Fri, 22 Jun 2007 23:50:09 Z</pubDate>
      <itunes:author>roman_pearce</itunes:author>
      <author>roman_pearce</author>
    </item>
  </channel>
</rss>