<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Lexicographic Permutations</title>
	<atom:link href="http://programmingpraxis.com/2010/03/09/lexicographic-permutations/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2010/03/09/lexicographic-permutations/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Sat, 11 Feb 2012 09:48:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Valentin</title>
		<link>http://programmingpraxis.com/2010/03/09/lexicographic-permutations/#comment-1481</link>
		<dc:creator><![CDATA[Valentin]]></dc:creator>
		<pubDate>Sun, 25 Jul 2010 19:44:23 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2047#comment-1481</guid>
		<description><![CDATA[Here is mine: http://codepad.org/QEWvFfu5

Far from the beauty of Knuth version implemented here by Mike but it was my first time to attempt to resolve such problem.]]></description>
		<content:encoded><![CDATA[<p>Here is mine: <a href="http://codepad.org/QEWvFfu5" rel="nofollow">http://codepad.org/QEWvFfu5</a></p>
<p>Far from the beauty of Knuth version implemented here by Mike but it was my first time to attempt to resolve such problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: programmingpraxis</title>
		<link>http://programmingpraxis.com/2010/03/09/lexicographic-permutations/#comment-1205</link>
		<dc:creator><![CDATA[programmingpraxis]]></dc:creator>
		<pubDate>Thu, 29 Apr 2010 01:09:44 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2047#comment-1205</guid>
		<description><![CDATA[As explained in the next sentence, the lexicographic order runs from right-to-left, rather than left-to-right, because it is easier when using lists to work at the head of the list, which must be the end (tail) of the permutation. ]]></description>
		<content:encoded><![CDATA[<p>As explained in the next sentence, the lexicographic order runs from right-to-left, rather than left-to-right, because it is easier when using lists to work at the head of the list, which must be the end (tail) of the permutation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://programmingpraxis.com/2010/03/09/lexicographic-permutations/#comment-1204</link>
		<dc:creator><![CDATA[Mike]]></dc:creator>
		<pubDate>Thu, 29 Apr 2010 01:03:21 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2047#comment-1204</guid>
		<description><![CDATA[In lexicogrphic order, isn&#039;t (1,2,3,4) followed by (1,2,4,3)?

Anyway, my python version of a generator that returns successive permutations in order.

[sourcecode lang=&quot;python&quot;]
def permutations_of( seq ):
    yield seq
    seqlen = len(seq)
    while True:
        j = seqlen - 2
        while j &gt;= 0 and seq[j] &gt;= seq[j+1]:
            j -= 1

        if j &lt; 0: break
        
        i= seqlen - 1
        while i &gt; j and seq[i] &lt; seq[j]:
            i -= 1
                
        seq[j],seq[i] = seq[i],seq[j]
        seq[j+1:] = seq[-1:j:-1]
        yield seq
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>In lexicogrphic order, isn&#8217;t (1,2,3,4) followed by (1,2,4,3)?</p>
<p>Anyway, my python version of a generator that returns successive permutations in order.</p>
<pre class="brush: python;">
def permutations_of( seq ):
    yield seq
    seqlen = len(seq)
    while True:
        j = seqlen - 2
        while j &gt;= 0 and seq[j] &gt;= seq[j+1]:
            j -= 1

        if j &lt; 0: break

        i= seqlen - 1
        while i &gt; j and seq[i] &lt; seq[j]:
            i -= 1

        seq[j],seq[i] = seq[i],seq[j]
        seq[j+1:] = seq[-1:j:-1]
        yield seq
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://programmingpraxis.com/2010/03/09/lexicographic-permutations/#comment-1066</link>
		<dc:creator><![CDATA[Jeff]]></dc:creator>
		<pubDate>Tue, 09 Mar 2010 18:13:38 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2047#comment-1066</guid>
		<description><![CDATA[Interesting.  My implementation (http://blog.jeffbergman.com/2010/03/09/permutation-generation-in-f-sharp/) was solving a slightly different problem in that I am printing all permutations of all combinations of elements in the list in lexicographic order.  For instance, for the list (1,2,3) I print all permutations of the lists (1), (1,2), (1,3), (2,3), and (1,2,3).]]></description>
		<content:encoded><![CDATA[<p>Interesting.  My implementation (<a href="http://blog.jeffbergman.com/2010/03/09/permutation-generation-in-f-sharp/" rel="nofollow">http://blog.jeffbergman.com/2010/03/09/permutation-generation-in-f-sharp/</a>) was solving a slightly different problem in that I am printing all permutations of all combinations of elements in the list in lexicographic order.  For instance, for the list (1,2,3) I print all permutations of the lists (1), (1,2), (1,3), (2,3), and (1,2,3).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Remco Niemeijer</title>
		<link>http://programmingpraxis.com/2010/03/09/lexicographic-permutations/#comment-1065</link>
		<dc:creator><![CDATA[Remco Niemeijer]]></dc:creator>
		<pubDate>Tue, 09 Mar 2010 10:21:09 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2047#comment-1065</guid>
		<description><![CDATA[My Haskell solution (see http://bonsaicode.wordpress.com/2010/03/09/programming-praxis-lexicographic-permutations/ for a version with comments):

[sourcecode lang=&quot;css&quot;]
import Data.List
import qualified Data.List.Key as K

perms :: (a -&gt; a -&gt; Bool) -&gt; [a] -&gt; [[a]]
perms cmp xs = map fst . K.sort (reverse . snd) . map unzip $
               permutations [(x, length $ filter (cmp x) xs) &#124; x &lt;- xs]
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>My Haskell solution (see <a href="http://bonsaicode.wordpress.com/2010/03/09/programming-praxis-lexicographic-permutations/" rel="nofollow">http://bonsaicode.wordpress.com/2010/03/09/programming-praxis-lexicographic-permutations/</a> for a version with comments):</p>
<pre class="brush: css;">
import Data.List
import qualified Data.List.Key as K

perms :: (a -&gt; a -&gt; Bool) -&gt; [a] -&gt; [[a]]
perms cmp xs = map fst . K.sort (reverse . snd) . map unzip $
               permutations [(x, length $ filter (cmp x) xs) | x &lt;- xs]
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Programming Praxis &#8211; Lexicographic Permutations &#171; Bonsai Code</title>
		<link>http://programmingpraxis.com/2010/03/09/lexicographic-permutations/#comment-1064</link>
		<dc:creator><![CDATA[Programming Praxis &#8211; Lexicographic Permutations &#171; Bonsai Code]]></dc:creator>
		<pubDate>Tue, 09 Mar 2010 10:20:48 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2047#comment-1064</guid>
		<description><![CDATA[[...] Praxis &#8211; Lexicographic&#160;Permutations By Remco Niemeijer  In today&#8217;s Programming Praxis exercise we have to generate all the lexicographic permutations of a list. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Praxis &#8211; Lexicographic&nbsp;Permutations By Remco Niemeijer  In today&#8217;s Programming Praxis exercise we have to generate all the lexicographic permutations of a list. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

