<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LAMBDAPHONE &#187; short</title>
	<atom:link href="http://coder.bsimmons.name/blog/tag/short/feed/" rel="self" type="application/rss+xml" />
	<link>http://coder.bsimmons.name/blog</link>
	<description>fragmentary ideas  ䷿  intellectual what-nots  ䷷  and haskell programming  ䷴</description>
	<lastBuildDate>Sun, 29 Jan 2012 17:24:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Working with Template Haskell in GHCi</title>
		<link>http://coder.bsimmons.name/blog/2010/12/working-with-template-haskell-in-ghci/</link>
		<comments>http://coder.bsimmons.name/blog/2010/12/working-with-template-haskell-in-ghci/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 17:20:04 +0000</pubDate>
		<dc:creator>jberryman</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[short]]></category>
		<category><![CDATA[TH]]></category>

		<guid isPermaLink="false">http://coder.bsimmons.name/blog/?p=507</guid>
		<description><![CDATA[<p>I&#8217;ve just started trying to learn and debug <a href="http://www.haskell.org/haskellwiki/Template_Haskell">Template Haskell</a> and found it a bit rough trying to explore TH interactively, but a couple of things have helped.</p>
<p>First and most obvious, we can use runQ to see the&#8230; <a href="http://coder.bsimmons.name/blog/2010/12/working-with-template-haskell-in-ghci/" class="read_more">   [ R E A D &#124; M O R E ]</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just started trying to learn and debug <a href="http://www.haskell.org/haskellwiki/Template_Haskell">Template Haskell</a> and found it a bit rough trying to explore TH interactively, but a couple of things have helped.</p>
<p>First and most obvious, we can use runQ to see the abstract TH syntax which a quasi-quoted expression expands to:</p>
<blockquote><pre><em>Prelude></em> <strong>:set -XTemplateHaskell</strong>
<em>Prelude></em> <strong>:m + Language.Haskell.TH</strong>
<em>Prelude Language.Haskell.TH></em> <strong>runQ [| \a -> a+1 |]</strong>
LamE [VarP a_1] (InfixE (Just (VarE a_1)) (VarE GHC.Num.+) (Just (LitE (IntegerL 1))))</pre>
</blockquote>
<p><span id="more-507"></span><br />
The second thing that was really helpful to me was turning on the <em>dump-splices</em> debugging option which causes GHC to print the expansions of all <code>$(top-level splices)</code>:</p>
<blockquote><pre><em>Prelude Language.Haskell.TH></em> <strong>:set -ddump-splices </strong>
<em>Prelude Language.Haskell.TH></em> <strong>:l Zipper.hs</strong>
[1 of 1] Compiling Zipper           ( Zipper.hs, interpreted )
Zipper.hs:1:0:
    Zipper.hs:1:0: Splicing declarations
        mkLabelsNoTypes ['Test]
      ======>
        Zipper.hs:119:2-25
        t1 = lens _t1 (\ b a -> a {_t1 = b})
        t2 = lens _t2 (\ b a -> a {_t2 = b})
Zipper.hs:1:0:
    Zipper.hs:1:0: Splicing declarations
        mkLabelsNoTypes ['Zipper]
      ======>
        Zipper.hs:123:2-27
        lStack = lens stack (\ b a -> a {stack = b})
        focus = lens _focus (\ b a -> a {_focus = b})
Ok, modules loaded: Zipper.</pre>
</blockquote>
<p>You can use splices directly in GHCi with the XTemplateHaskell extension turned on (although you get some funny output with <em>-ddump-splices</em>, perhaps related to <a href="http://www.mail-archive.com/glasgow-haskell-bugs@haskell.org/msg11003.html">this</a>):</p>
<blockquote><pre><em>*Zipper Language.Haskell.TH></em> <strong>let tup = $(tupE $ take 4 $ cycle [ [| "hi" |] , [| 5 |] ])</strong>
<em>*Zipper Language.Haskell.TH></em> <strong>tup</strong>
("hi",5,"hi",5)
</pre>
</blockquote>
<p>That&#8217;s all for now! Let me know if you have any tips and I&#8217;ll add them here.</p>
]]></content:encoded>
			<wfw:commentRss>http://coder.bsimmons.name/blog/2010/12/working-with-template-haskell-in-ghci/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>17&#215;17: some Simulated Annealing updates</title>
		<link>http://coder.bsimmons.name/blog/2010/07/17x17-some-simulated-annealing-updates/</link>
		<comments>http://coder.bsimmons.name/blog/2010/07/17x17-some-simulated-annealing-updates/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 02:46:06 +0000</pubDate>
		<dc:creator>jberryman</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[17x17]]></category>
		<category><![CDATA[Graph Theory]]></category>
		<category><![CDATA[heuristics]]></category>
		<category><![CDATA[short]]></category>
		<category><![CDATA[theory]]></category>

		<guid isPermaLink="false">http://coder.bsimmons.name/blog/?p=459</guid>
		<description><![CDATA[<blockquote><p><em>Note: this is part of a <a href="http://coder.bsimmons.name/blog/tag/17x17/">series of posts</a> is related to the &#8220;<a href="http://blog.computationalcomplexity.org/2009/11/17x17-challenge-worth-28900-this-is-not.html">17&#215;17 Challenge</a>&#8221; posted by Bill Gasarch. The goal is to color cells of a 17 by 17 grid, using only four colors, such that no</em></p></blockquote><p>&#8230; <a href="http://coder.bsimmons.name/blog/2010/07/17x17-some-simulated-annealing-updates/" class="read_more">   [ R E A D &#124; M O R E ]</a></p>]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>Note: this is part of a <a href="http://coder.bsimmons.name/blog/tag/17x17/">series of posts</a> is related to the &#8220;<a href="http://blog.computationalcomplexity.org/2009/11/17x17-challenge-worth-28900-this-is-not.html">17&#215;17 Challenge</a>&#8221; posted by Bill Gasarch. The goal is to color cells of a 17 by 17 grid, using only four colors, such that no rectangle is formed from four cells of the same color.</em></p></blockquote>
<p>Just a few follow-ups to my previous <a href="http://coder.bsimmons.name/blog/2010/07/17x17-a-simulated-annealing-approach-using-thresholds/">post in which I use a simulated annealing-type algorithm</a> to find a good (hopefully complete) cover of a grid by swapping rows and columns from four identical sub-grids of 74 colors.</p>
<h2>Easing into new thresholds</h2>
<p>I modified my algorithm so that the likelihood of jumping into the highest permitted energy level is decreased over time; thus instead of having an abrupt transition to a new threshold, resulting in a steep dive, we instead <em>ease into</em> the new energy level. </p>
<p>Here is a graph of a run with the adjusted meta-heuristic (in blue) alongside a previous abrupt threshold transition run (in black). You can check compare it to the <a href="http://coder.bsimmons.name/blog/wp-content/uploads/5-2.combined-annotated.png">graph from the previous post</a>:</p>
<p><a href="http://coder.bsimmons.name/blog/wp-content/uploads/output.10000.5.smooth_vs_jagged.png"><img src="http://coder.bsimmons.name/blog/wp-content/uploads/output.10000.5.smooth_vs_jagged-300x81.png" alt="a more smooth graph vs. a graph with abrupt changes at each threshold change" title="output.10000.5.smooth_vs_jagged" width="300" height="81" class="aligncenter size-medium wp-image-460" /></a></p>
<p><span id="more-459"></span></p>
<p>Unfortunately this change didn&#8217;t cause any improvement in the solutions generated. They still seem to flatten at a grid with 19 &#8211; 22 uncolored cells.</p>
<h2>Testing a combination of sub-grids with known good solution</h2>
<p>I wondered if the lower bound I was smacking into was caused by the fact that I was trying to find a combination of four permutations <em>of the same subset</em>, and perhaps this particular subset didn&#8217;t mesh all that well with itself.</p>
<p>In the original blog posting laying out this challenge there is four-coloring of 17&#215;17 with only one cell left un-colorable in a truly painful refactoring process, I modified my script to take four separate and distinct sub-grids and perform the same shuffling procedure.</p>
<p>Rather than find the original arrangement of the colored subsets or one nearly as good, the program settles on a solution with around 30 uncolored cells. That is worse than my original version, corresponding to the fact that there are fewer cells to work with in this latter set of colored subsets: 288 vs. 296.</p>
<h2>Conclusion</h2>
<p>This doesn&#8217;t say anything about whether a full-cover can likely be obtained by permuting four overlapping copies of a single subset of colors. It does tell us that either my code is flawed, this isn&#8217;t a particularly effective method for this kind of search, or it needs to be tuned better.</p>
]]></content:encoded>
			<wfw:commentRss>http://coder.bsimmons.name/blog/2010/07/17x17-some-simulated-annealing-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>17&#215;17: Symmetric Single-Colorings and some Graph Theory</title>
		<link>http://coder.bsimmons.name/blog/2010/03/17x17-symmetric-single-colorings-and-some-graph-theory/</link>
		<comments>http://coder.bsimmons.name/blog/2010/03/17x17-symmetric-single-colorings-and-some-graph-theory/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 17:44:07 +0000</pubDate>
		<dc:creator>jberryman</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[17x17]]></category>
		<category><![CDATA[Graph Theory]]></category>
		<category><![CDATA[short]]></category>

		<guid isPermaLink="false">http://coder.bsimmons.name/blog/?p=355</guid>
		<description><![CDATA[<blockquote><p><em>Note: this is part of a <a href="http://coder.bsimmons.name/blog/tag/17x17/">series of posts</a> is related to the &#8220;<a href="http://blog.computationalcomplexity.org/2009/11/17x17-challenge-worth-28900-this-is-not.html">17&#215;17 Challenge</a>&#8221; posted by Bill Gasarch. The goal is to color cells of a 17 by 17 grid, using only four colors, such that no</em></p></blockquote><p>&#8230; <a href="http://coder.bsimmons.name/blog/2010/03/17x17-symmetric-single-colorings-and-some-graph-theory/" class="read_more">   [ R E A D &#124; M O R E ]</a></p>]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>Note: this is part of a <a href="http://coder.bsimmons.name/blog/tag/17x17/">series of posts</a> is related to the &#8220;<a href="http://blog.computationalcomplexity.org/2009/11/17x17-challenge-worth-28900-this-is-not.html">17&#215;17 Challenge</a>&#8221; posted by Bill Gasarch. The goal is to color cells of a 17 by 17 grid, using only four colors, such that no rectangle is formed from four cells of the same color.</em></p></blockquote>
<p>In my <a href="http://coder.bsimmons.name/blog/2010/03/17x17-some-thoughts-on-the-problem/">last post</a> I noticed that all of the smaller optimal single-colorings I generated showed diagonal symmetry, meaning that row 1 is the same as column 1, row 8 is the same as column 8, etc. It&#8217;s my hypothesis that all complete single-colorings are symmetrical in this way. </p>
<p>I decided to play with making the known 74-cell subset symmetrical by applying rotations and came up with this:</p>
<blockquote><p><iframe width='425' height='400' frameborder='0' src='http://spreadsheets.google.com/pub?key=t-3KjM7Nt7-9AmYg9uCi5Xg&#038;single=true&#038;gid=0&#038;output=html&#038;widget=true'></iframe></p></blockquote>
<p><span id="more-355"></span></p>
<p>Figuring out an <a href="http://en.wikipedia.org/wiki/Graph_automorphism">automorphism</a> that would give me that diagonal symmetry was easier than inputting the original points into Google Spreadsheet. The colors show the hints that helped anchor the rotations. (I&#8217;m going to try to come up with an algorithm for permuting a grid into a symmetrical form).</p>
<p>It seems that symmetry is a very interesting quality in a <a href="http://en.wikipedia.org/wiki/Graph_%28mathematics%29">graph</a>, but when the Graph Theorists study <a href="http://en.wikipedia.org/wiki/Symmetric_graph">symmetric graphs</a>, they are looking at graphs with where (as I understand it)</p>
<blockquote><p>
any two linked vertices can be mapped onto any to other linked vertices, resulting in essentially the same graph</p></blockquote>
<p>&#8230;which is much cooler. Another interesting thing to mention is that a valid coloring is essentially a <a href="http://en.wikipedia.org/wiki/Hypergraph">hypergraph</a> where the higher dimensional edges are the row/column relationship. It can be flattened into a graph in any number of ways, for example by connecting every colored cell with it&#8217;s four neighbors (possibly itself).</p>
<p>So up next for me is a brute force algorithm for single-colorings generated symmetrically. </p>
]]></content:encoded>
			<wfw:commentRss>http://coder.bsimmons.name/blog/2010/03/17x17-symmetric-single-colorings-and-some-graph-theory/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An alternative definition for Data.List.groupBy</title>
		<link>http://coder.bsimmons.name/blog/2010/02/an-alternative-definition-for-datalistgroupby/</link>
		<comments>http://coder.bsimmons.name/blog/2010/02/an-alternative-definition-for-datalistgroupby/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 18:15:50 +0000</pubDate>
		<dc:creator>jberryman</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[short]]></category>
		<category><![CDATA[sorting]]></category>

		<guid isPermaLink="false">http://coder.bsimmons.name/blog/?p=318</guid>
		<description><![CDATA[<p>The function <a href="http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Data-List.html#v:groupBy"><code>groupBy</code></a> from haskell&#8217;s standard library is defined in terms of <code>span</code>, the effect being that the supplied predicate function is used to compare the first element of a group with successive elements.</p>
<p>This isn&#8217;t clear from the&#8230; <a href="http://coder.bsimmons.name/blog/2010/02/an-alternative-definition-for-datalistgroupby/" class="read_more">   [ R E A D &#124; M O R E ]</a></p>]]></description>
			<content:encoded><![CDATA[<p>The function <a href="http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Data-List.html#v:groupBy"><code>groupBy</code></a> from haskell&#8217;s standard library is defined in terms of <code>span</code>, the effect being that the supplied predicate function is used to compare the first element of a group with successive elements.</p>
<p>This isn&#8217;t clear from the docs, and you might try to do this and wonder at the output you got:</p>
<blockquote><pre>*Main> groupBy (< =) [3,4,5,3,2,1,4,4,1,1,2,3,4,5,4,5,6,7]
[[3,4,5,3],[2],[1,4,4,1,1,2,3,4,5,4,5,6,7]]</pre>
</pre>
</blockquote>
<p><span id="more-318"></span></p>
<p>We can redefine <code>groupBy</code> as follows, so that the supplied predicate function compares adjacent elements one-by-one and returns <code>True</code> if they should be grouped together:</p>
<p><blockquote class="vimblock"><br />
<span class="Comment">&gt;</span>&nbsp;groupBy' <span class="Statement">::</span>&nbsp;(a&nbsp;<span class="Statement">-&gt;</span>&nbsp;a&nbsp;<span class="Statement">-&gt;</span>&nbsp;<span class="Type">Bool</span>)&nbsp;<span class="Statement">-&gt;</span>&nbsp;[a]&nbsp;<span class="Statement">-&gt;</span>&nbsp;[[a]]<br />
<span class="Comment">&gt;</span>&nbsp;groupBy' c&nbsp;[]&nbsp;&nbsp;&nbsp;&nbsp; <span class="Statement">=</span>&nbsp;[]<br />
<span class="Comment">&gt;</span>&nbsp;groupBy' c&nbsp;(a<span class="Statement">:</span>as)&nbsp;<span class="Statement">=</span>&nbsp;(a<span class="Statement">:</span>ys)&nbsp;<span class="Statement">:</span>&nbsp;groupBy' c&nbsp;zs<br />
<span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp; <span class="Type">where</span>&nbsp;(ys,zs)&nbsp;<span class="Statement">=</span>&nbsp;spanC&nbsp;a&nbsp;as<br />
<span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spanC&nbsp;_&nbsp;&nbsp;[]&nbsp;&nbsp;&nbsp;&nbsp;<span class="Statement">=</span>&nbsp;([],&nbsp;[])<br />
<span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spanC&nbsp;a' (x<span class="Statement">:</span>xs)<br />
<span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="Statement">|</span>&nbsp;a' <span class="Statement">`c`</span>&nbsp;x&nbsp;&nbsp; <span class="Statement">=</span>&nbsp;<span class="Statement">let</span>&nbsp;(ps,qs)&nbsp;<span class="Statement">=</span>&nbsp;spanC&nbsp;x&nbsp;xs&nbsp;<br />
<span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Statement">in</span>&nbsp;(x<span class="Statement">:</span>ps,qs)<br />
<span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="Statement">|</span>&nbsp;<span class="Identifier">otherwise</span>&nbsp;<span class="Statement">=</span>&nbsp;([],&nbsp;x<span class="Statement">:</span>xs)<br />
<br /></blockquote></p>
<p>Now we can use the <code>groupBy</code> function to return a list of ascending lists, like we (probably) wanted:</p>
<blockquote><pre>*Main> groupBy' (< =) [3,4,5,3,2,1,4,4,1,1,2,3,4,5,4,5,6,7]
[[3,4,5],[3],[2],[1,4,4],[1,1,2,3,4,5],[4,5,6,7]]</pre>
</pre>
</blockquote>
<p>The functionality is of course the same for <code>groupBy (==)</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://coder.bsimmons.name/blog/2010/02/an-alternative-definition-for-datalistgroupby/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Definition of Data.List.group</title>
		<link>http://coder.bsimmons.name/blog/2010/02/the-definition-of-datalistgroup/</link>
		<comments>http://coder.bsimmons.name/blog/2010/02/the-definition-of-datalistgroup/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 16:00:40 +0000</pubDate>
		<dc:creator>jberryman</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[short]]></category>

		<guid isPermaLink="false">http://coder.bsimmons.name/blog/?p=312</guid>
		<description><![CDATA[<p>I&#8217;ve been thinking quite a bit lately about a category of functions that are always a bit awkward to define: they involve cases where we would like to traverse a recursive data structure and do something with the data that&#8230; <a href="http://coder.bsimmons.name/blog/2010/02/the-definition-of-datalistgroup/" class="read_more">   [ R E A D &#124; M O R E ]</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking quite a bit lately about a category of functions that are always a bit awkward to define: they involve cases where we would like to traverse a recursive data structure and do something with the data that we have passed over but which is &#8220;gone now&#8221;.<br />
<span id="more-312"></span><br />
There are many examples of functions like these in the haskell standard libraries: <code><a href="http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/src/GHC-List.html#span">span</a></code>, <code><a href="http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/src/GHC-List.html#splitAt">splitAt</a></code>, etc.</p>
<p>A function like <code>group</code> is in this category. It&#8217;s conceptually very simple, but defining it actually requires a bit of indirection. Here I&#8217;ve translated the definition from <code>Data.List</code> to use explicit recursion:</p>
<p><blockquote class="vimblock"><br />
<span class="lnr">66 </span><span class="Comment">&gt;</span>&nbsp;group&nbsp;<span class="Statement">::</span>&nbsp;(<span class="Type">Eq</span>&nbsp;a)&nbsp;<span class="Statement">=&gt;</span>&nbsp;[a]&nbsp;<span class="Statement">-&gt;</span>&nbsp;[[a]]<br />
<span class="lnr">67 </span><span class="Comment">&gt;</span>&nbsp;group&nbsp;[]&nbsp;&nbsp;&nbsp;&nbsp; <span class="Statement">=</span>&nbsp;[]<br />
<span class="lnr">68 </span><span class="Comment">&gt;</span>&nbsp;group&nbsp;(a<span class="Statement">:</span>as)&nbsp;<span class="Statement">=</span>&nbsp;(a<span class="Statement">:</span>ys)&nbsp;<span class="Statement">:</span>&nbsp;group&nbsp;zs<br />
<span class="lnr">69 </span><span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp; <span class="Type">where</span>&nbsp;(ys,zs)&nbsp;<span class="Statement">=</span>&nbsp;spanEq&nbsp;as<br />
<span class="lnr">70 </span><span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spanEq&nbsp;[]&nbsp;&nbsp;&nbsp;&nbsp; <span class="Statement">=</span>&nbsp;([],&nbsp;[])<br />
<span class="lnr">71 </span><span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spanEq&nbsp;(x<span class="Statement">:</span>xs)<br />
<span class="lnr">72 </span><span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="Statement">|</span>&nbsp;a&nbsp;<span class="Statement">==</span>&nbsp;x&nbsp;&nbsp;&nbsp;&nbsp;<span class="Statement">=</span>&nbsp;<span class="Statement">let</span>&nbsp;(ps,qs)&nbsp;<span class="Statement">=</span>&nbsp;spanEq&nbsp;xs&nbsp;<br />
<span class="lnr">73 </span><span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Statement">in</span>&nbsp;(x<span class="Statement">:</span>ps,qs)<br />
<span class="lnr">74 </span><span class="Comment">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="Statement">|</span>&nbsp;<span class="Identifier">otherwise</span>&nbsp;<span class="Statement">=</span>&nbsp;([],&nbsp;x<span class="Statement">:</span>xs)<br />
<span class="lnr">75 </span><br />
<br /></blockquote></p>
<p>I think if I were asked to define this having never seen it, the first thing I would think of would be something using <code>foldl1</code>, which wouldn&#8217;t work.</p>
<p><em><strong>EDIT</strong>:</em> see also <a href="http://coder.bsimmons.name/blog/2010/02/an-alternative-definition-for-datalistgroupby/">an alternative definition for Data.List.groupBy</a></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.bsimmons.name/blog/2010/02/the-definition-of-datalistgroup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk
Database Caching 8/15 queries in 0.033 seconds using disk

Served from: coder.bsimmons.name @ 2012-02-05 11:13:15 -->
