<?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/"
	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>Data.Syntaxfree</title>
	<atom:link href="http://syntaxfree.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://syntaxfree.wordpress.com</link>
	<description>Haskell programming journal</description>
	<lastBuildDate>Thu, 24 Apr 2008 01:33:57 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='syntaxfree.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/776349099b72a8626f110d994305c12e?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Data.Syntaxfree</title>
		<link>http://syntaxfree.wordpress.com</link>
	</image>
			<item>
		<title>(An additional note on the new blog)</title>
		<link>http://syntaxfree.wordpress.com/2008/04/24/an-additional-note-on-the-new-blog/</link>
		<comments>http://syntaxfree.wordpress.com/2008/04/24/an-additional-note-on-the-new-blog/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 01:33:57 +0000</pubDate>
		<dc:creator>Macx</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://syntaxfree.wordpress.com/?p=59</guid>
		<description><![CDATA[I&#8217;m studying modal logic with the  Konyndyk textbook and (the philosophical aspect) of kripkean semantics with &#8220;Naming and necessity&#8221;. That should be a factor on deciding whether the new blog goes or not to planet haskell, as the recent drug-oriented material isn&#8217;t representative of *everything* I like about the world.
      [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=59&subd=syntaxfree&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;m studying modal logic with the  Konyndyk textbook and (the philosophical aspect) of kripkean semantics with &#8220;Naming and necessity&#8221;. That should be a factor on deciding whether the new blog goes or not to planet haskell, as the recent drug-oriented material isn&#8217;t representative of *everything* I like about the world.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/syntaxfree.wordpress.com/59/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/syntaxfree.wordpress.com/59/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/syntaxfree.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/syntaxfree.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/syntaxfree.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/syntaxfree.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/syntaxfree.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/syntaxfree.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/syntaxfree.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/syntaxfree.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/syntaxfree.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/syntaxfree.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=59&subd=syntaxfree&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://syntaxfree.wordpress.com/2008/04/24/an-additional-note-on-the-new-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8aa2998eff18104553c29943cfd383cc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Macx</media:title>
		</media:content>
	</item>
		<item>
		<title>I shall no longer be blogging here</title>
		<link>http://syntaxfree.wordpress.com/2008/04/24/i-shall-no-longer-be-blogging-here/</link>
		<comments>http://syntaxfree.wordpress.com/2008/04/24/i-shall-no-longer-be-blogging-here/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 01:26:14 +0000</pubDate>
		<dc:creator>Macx</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://syntaxfree.wordpress.com/?p=58</guid>
		<description><![CDATA[I&#8217;m moving all my blogging activity &#8212; I even transported the posts and comments from here &#8212; to dayvancowboy.org.
 
Whether the address at Planet Haskell should be changed is a judgement call on the Planet Haskell admins as the new blog contains vast amounts of nonhaskell material, (there is some maths though), but basically anyone who [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=58&subd=syntaxfree&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;m moving all my blogging activity &#8212; I even transported the posts and comments from here &#8212; to <a href="http://dayvancowboy.org">dayvancowboy.org</a>.</p>
<p> </p>
<p>Whether the address at Planet Haskell should be changed is a judgement call on the Planet Haskell admins as the new blog contains vast amounts of nonhaskell material, (there is some maths though), but basically anyone who came to care about me as an individual should subscribe to the rss feed at that blog.</p>
<p> </p>
<p>Kthxbye. [:P]</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/syntaxfree.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/syntaxfree.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/syntaxfree.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/syntaxfree.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/syntaxfree.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/syntaxfree.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/syntaxfree.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/syntaxfree.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/syntaxfree.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/syntaxfree.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/syntaxfree.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/syntaxfree.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=58&subd=syntaxfree&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://syntaxfree.wordpress.com/2008/04/24/i-shall-no-longer-be-blogging-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8aa2998eff18104553c29943cfd383cc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Macx</media:title>
		</media:content>
	</item>
		<item>
		<title>Is last.fm leaking information to Google?</title>
		<link>http://syntaxfree.wordpress.com/2007/07/04/is-lastfm-leaking-information-to-google/</link>
		<comments>http://syntaxfree.wordpress.com/2007/07/04/is-lastfm-leaking-information-to-google/#comments</comments>
		<pubDate>Wed, 04 Jul 2007 02:07:42 +0000</pubDate>
		<dc:creator>Macx</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://syntaxfree.wordpress.com/2007/07/04/is-lastfm-leaking-information-to-google/</guid>
		<description><![CDATA[I use last.fm, which means in effect I&#8217;m giving up large ammounts of privacy &#8212; the kind of music I listen to  &#8212; for the sake of social networking (which in the end I don&#8217;t use at all) and fun stats. And that&#8217;s okay; at least the terms of service assure me that
We won&#8217;t [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=55&subd=syntaxfree&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I use last.fm, which means in effect I&#8217;m giving up large ammounts of privacy &#8212; the kind of music I listen to  &#8212; for the sake of social networking (which in the end I don&#8217;t use at all) and fun stats. And that&#8217;s okay; at least the terms of service assure me that</p>
<blockquote><p>We won&#8217;t pass your email address on to anyone, not even Lars Ulrich at gunpoint.</p></blockquote>
<p>Sure, it also claims that</p>
<blockquote><p>We reserve the right to sell or license pseudonymous listening data for commercial use, however we will never sell your personal data that can be traced back to a specific user. We may, for example, license our weekly charts for commercial use. This would not compromise any personal information.</p></blockquote>
<p>But then today I started getting ads in hebrew characters in my Gmail. I don&#8217;t ever receive or send emails with hebrew characters, or in Hebrew, or related to Israel in any kind or form.</p>
<p><a href="http://syntaxfree.files.wordpress.com/2007/07/gmail-hebrew.jpg" title="gmail-hebrew.jpg"><img src="http://syntaxfree.files.wordpress.com/2007/07/gmail-hebrew.jpg" alt="gmail-hebrew.jpg" width="100%" /></p>
<p>click for full size<br />
</a></p>
<p>As you can see, my Gmail is set to portuguese language, and except for automated newsletters most every email I receive or send is in portuguese. I&#8217;ve been intrigued for most of the day.  Then, just fifteen minutes ago, a friend was complaining about an annoying message she had been sent on last.fm. I went there to check and saw this:</p>
<p><a href="http://syntaxfree.files.wordpress.com/2007/07/lastm-hebrew.jpg" title="lastm-hebrew.jpg"><img src="http://syntaxfree.files.wordpress.com/2007/07/lastm-hebrew.jpg" alt="lastm-hebrew.jpg"></p>
<p>click for full size</a></p>
<p>As you can see clearly on the right it says &#8220;Link patrocinado&#8221;, which means &#8220;Sponsored link&#8221;. It&#8217;s not a feed I subscribe to.</p>
<p>Of course, just this morning I dusted off a CD I had received as a gift when I was a teenager and ripped it to iTunes. The title on the cover says &#8220;Hava Nagila and other Jewish Melodies&#8221;, but the CDDB-derived title was written in hebrew characters.</p>
<p>And then the two things clicked. What kind of sinister coincidence is this?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/syntaxfree.wordpress.com/55/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/syntaxfree.wordpress.com/55/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/syntaxfree.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/syntaxfree.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/syntaxfree.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/syntaxfree.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/syntaxfree.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/syntaxfree.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/syntaxfree.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/syntaxfree.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/syntaxfree.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/syntaxfree.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=55&subd=syntaxfree&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://syntaxfree.wordpress.com/2007/07/04/is-lastfm-leaking-information-to-google/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8aa2998eff18104553c29943cfd383cc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Macx</media:title>
		</media:content>

		<media:content url="http://syntaxfree.files.wordpress.com/2007/07/gmail-hebrew.jpg" medium="image">
			<media:title type="html">gmail-hebrew.jpg</media:title>
		</media:content>

		<media:content url="http://syntaxfree.files.wordpress.com/2007/07/lastm-hebrew.jpg" medium="image">
			<media:title type="html">lastm-hebrew.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>This might or might not qualify as a theorem prover</title>
		<link>http://syntaxfree.wordpress.com/2007/06/13/this-might-or-might-not-qualify-as-a-theorem-prover/</link>
		<comments>http://syntaxfree.wordpress.com/2007/06/13/this-might-or-might-not-qualify-as-a-theorem-prover/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 08:01:16 +0000</pubDate>
		<dc:creator>Macx</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://syntaxfree.wordpress.com/2007/06/13/this-might-or-might-not-qualify-as-a-theorem-prover/</guid>
		<description><![CDATA[Just been implementing sentential logic as I progress through the textbook.


module Main where
import Control.Monad

data Formula a =
			 Prim a
			 &#124; (Formula a) :+ (Formula a)
			 &#124; (Formula a) :* (Formula a)
			 &#124; (Formula a) :-&#62; (Formula a)
			 &#124; Not (Formula a) deriving Show

(&#60;-&#62;)  :: (Formula a) -&#62; (Formula a) -&#62; (Formula a)
a &#60;-&#62; b [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=54&subd=syntaxfree&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Just been implementing <a href="http://www.fecundity.com/logic/">sentential logic</a> as I progress through the textbook.</p>
<p><code></code></p>
<pre>
module Main where
import Control.Monad

data Formula a =
			 Prim a
			 | (Formula a) :+ (Formula a)
			 | (Formula a) :* (Formula a)
			 | (Formula a) :-&gt; (Formula a)
			 | Not (Formula a) deriving Show

(&lt;-&gt;)  :: (Formula a) -&gt; (Formula a) -&gt; (Formula a)
a &lt;-&gt; b = (a :-&gt; b)  :* (b :-&gt; a)
inv (a :-&gt; b) = b :-&gt; a

showP (a,b) = show a ++ "====&gt;" ++ show b ++ "n"
showF = putStr . unlines . map showP . map (k-&gt;(k, truth k))

bools =  fmap Prim [True, False]

arity1 f = map f bools
arity2 f = liftM2 f bools bools
arity3 f = liftM3 f bools bools bools

solve arity f = map truth (arity f)

taut1 f = all (==True) (solve arity1 f)
taut2 f = all (==True) (solve arity2 f)
taut3 f = all (==True) (solve arity3 f)

contr1 f = all (==False) (solve arity1 f)
contr2 f = all (==False) (solve arity2 f)
contr3 f = all (==False) (solve arity3 f)

conting1 f = (not (taut1 f)) &amp;&amp; (not (contr1 f))
conting2 f = (not (taut2 f)) &amp;&amp; (not (contr2 f))
conting3 f = (not (taut3 f)) &amp;&amp; (not (contr3 f))

equiv1 f g = all (==True) (zipWith (==) (solve arity1 f) (solve arity1 g))
equiv2 f g = all (==True) (zipWith (==) (solve arity2 f) (solve arity2 g))
equiv3 f g = all (==True) (zipWith (==) (solve arity3 f) (solve arity3 g))

consistent arity1 f arity2 g = any (==True) (zipWith (&amp;&amp;) (solve arity1 f) (solve arity2 g))

conseq prem1 prem2 concl = ((prem1 :* prem2) :-&gt; concl) 

truth :: (Formula Bool) -&gt; Bool
truth (Prim z) = z
truth (a :+ b) = (truth a) || (truth b)
truth (a :* b) = (truth a) &amp;&amp; (truth b)
truth (Not a) = not (truth a)
truth (a :-&gt; b) = ((truth a) == (truth b)) || (truth a == False) 

-- some examples
-- to print a truth table, use
-- showF $ arityN example
-- where arityN depends on the number of arguments.
-- or use tautN, contrN, etc. ex: taut1 lem

lem x = (Not (Not x)) &lt;-&gt; x
xor x y = (x :* (Not y)) :+ ((Not x) :* y)
hiti a b = (a :* b) :-&gt; b
gligli a b = (a :+ b) &lt;-&gt; (b :+ b)
compli c = ((c &lt;-&gt; c) :-&gt; c) :* (Not (c :-&gt; c))
minv m n p = m :* (n :+ p)</pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/syntaxfree.wordpress.com/54/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/syntaxfree.wordpress.com/54/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/syntaxfree.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/syntaxfree.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/syntaxfree.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/syntaxfree.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/syntaxfree.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/syntaxfree.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/syntaxfree.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/syntaxfree.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/syntaxfree.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/syntaxfree.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=54&subd=syntaxfree&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://syntaxfree.wordpress.com/2007/06/13/this-might-or-might-not-qualify-as-a-theorem-prover/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8aa2998eff18104553c29943cfd383cc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Macx</media:title>
		</media:content>
	</item>
		<item>
		<title>Magic Caesar autodecipher</title>
		<link>http://syntaxfree.wordpress.com/2007/05/13/magic-caesar-autodecipher/</link>
		<comments>http://syntaxfree.wordpress.com/2007/05/13/magic-caesar-autodecipher/#comments</comments>
		<pubDate>Sun, 13 May 2007 19:44:55 +0000</pubDate>
		<dc:creator>Macx</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://syntaxfree.wordpress.com/2007/05/13/magic-caesar-autodecipher/</guid>
		<description><![CDATA[ 

import Char
import List
charRot r w = let base = (if isUpper w then 65 else 97) in
    if (isAlpha w) then chr (base + (mod ((ord w) - base +r) 26)) else w
strRot r w = map (charRot r) w
unRot w = [strRot r w &#124; r&#60;-[1..26]]
countString st = [length (filter [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=51&subd=syntaxfree&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p> <code></p>
<pre>
import Char
import List
charRot r w = let base = (if isUpper w then 65 else 97) in
    if (isAlpha w) then chr (base + (mod ((ord w) - base +r) 26)) else w
strRot r w = map (charRot r) w
unRot w = [strRot r w | r&lt;-[1..26]]
countString st = [length (filter (==(chr x)) (map toLower st)) | x&lt;-[97..122]]
score w = sum $ zipWith (*) (map fromIntegral (countString w) )
[8.275745257452574e-2,1.3306233062330624e-2,
2.96239837398374e-2,3.848238482384824e-2,
0.13211043360433605,2.630420054200542e-2,
1.978319783197832e-2,5.9508807588075883e-2,
8.205962059620596e-2,1.3075880758807589e-3,
5.267615176151761e-3,4.563346883468835e-2,
2.640921409214092e-2,
6.775067750677507e-6,1.157520325203252e-2,
8.263550135501355e-2,2.1565040650406504e-2,
1.27710027100271e-3,
6.222560975609756e-2,7.654471544715447e-2,
9.862127371273713e-2,2.943428184281843e-2,
1.1646341463414634e-2,1.9173441734417346e-2,
2.0121951219512196e-3,2.005420054200542e-2,
6.741192411924119e-4]
autodeRot w = unlines $ map show $ sort [(score x, x)| x&lt;-(unRot w)]
main = do {
    name &lt;- getLine ;
    putStr (autodeRot name);
</pre>
<p></code></p>
<p>These are a few tests a friend did:</p>
<p><code> $ echo "WPE XP DPP TQ ESPDP SPFCTDETND LWW HZCV HPWW ZC YZE" |./magic</code></p>
<p>(2.167953929539295,&#8221;WPE XP DPP TQ ESPDP SPFCTDETND LWW HZCV HPWW ZC YZE&#8221;)</p>
<p>(2.1861212737127373,&#8221;ATI BT HTT XU IWTHT WTJGXHIXRH PAA LDGZ LTAA DG CDI&#8221;)</p>
<p>(2.5361686991869914,&#8221;LET ME SEE IF THESE HEURISTICS ALL WORK WELL OR NOT&#8221;)</p>
<p><code>$ echo SHUKDSV LWV D KROH,  FDQ BRX GLJ WKDW KROH RU FDQW BRX?SHUKDSV LWV D KROH,  FDQ BRX GLJ WKDW KROH RU FDQW BRX? | ./magic</code></p>
<p>(3.8078252032520323,&#8221;APCSLAD TED L SZWP, NLY JZF OTR ESLE SZWP ZC NLYE JZF?APCSLAD TED L SZWP, NLY JZF OTR ESLE SZWP ZC NLYE JZF?&#8221;)</p>
<p>(3.9856097560975607,&#8221;ETGWPEH XIH P WDAT, RPC NDJ SXV IWPI WDAT DG RPCI NDJ?ETGWPEH XIH P WDAT, RPC NDJ SXV IWPI WDAT DG RPCI NDJ?&#8221;)</p>
<p>(4.096321138211382,&#8221;QFSIBQT JUT B IPMF, DBO ZPV EJH UIBU IPMF PS DBOU ZPV?QFSIBQT JUT B IPMF, DBO ZPV EJH UIBU IPMF PS DBOU ZPV?&#8221;)</p>
<p>(4.201192411924119,&#8221;TIVLETW MXW E LSPI, GER CSY HMK XLEX LSPI SV GERX CSY?TIVLETW MXW E LSPI, GER CSY HMK XLEX LSPI SV GERX CSY?&#8221;)</p>
<p>(4.557330623306233,&#8221;PERHAPS ITS A HOLE, CAN YOU DIG THAT HOLE OR CANT YOU?PERHAPS ITS A HOLE, CAN YOU DIG THAT HOLE OR CANT YOU?&#8221;)</p>
<p><code>$ echo JG J VOEFSTUBOE UIF CBTJDT, NBZCF J DBO QVU BMM PG UIFN JOUP B CPY PS B DBO BOE TIBLF JU TP CBEMZ UIBU JU UVSOT JOUP TPNFUIJOH FMTF. | ./magic</code></p>
<p>(4.538712737127371,&#8221;MJ M YRHIVWXERH XLI FEWMGW, QECFI M GER TYX EPP SJ XLIQ MRXS E FSB SV E GER ERH WLEOI MX WS FEHPC XLEX MX XYVRW MRXS WSQIXLMRK IPWI.&#8221;)</p>
<p>(4.616466802168022,&#8221;UR U GZPQDEFMZP FTQ NMEUOE, YMKNQ U OMZ BGF MXX AR FTQY UZFA M NAJ AD M OMZ MZP ETMWQ UF EA NMPXK FTMF UF FGDZE UZFA EAYQFTUZS QXEQ.&#8221;)</p>
<p>(4.622029132791328,&#8221;JG J VOEFSTUBOE UIF CBTJDT, NBZCF J DBO QVU BMM PG UIFN JOUP B CPY PS B DBO BOE TIBLF JU TP CBEMZ UIBU JU UVSOT JOUP TPNFUIJOH FMTF.&#8221;)</p>
<p>(4.925511517615177,&#8221;TQ T FYOPCDELYO ESP MLDTND, XLJMP T NLY AFE LWW ZQ ESPX TYEZ L MZI ZC L NLY LYO DSLVP TE DZ MLOWJ ESLE TE EFCYD TYEZ DZXPESTYR PWDP.&#8221;)</p>
<p>(5.010033875338754,&#8221;XU X JCSTGHIPCS IWT QPHXRH, BPNQT X RPC EJI PAA DU IWTB XCID P QDM DG P RPC PCS HWPZT XI HD QPSAN IWPI XI IJGCH XCID HDBTIWXCV TAHT.&#8221;)</p>
<p>(5.256114498644987,&#8221;PM P BUKLYZAHUK AOL IHZPJZ, THFIL P JHU WBA HSS VM AOLT PUAV H IVE VY H JHU HUK ZOHRL PA ZV IHKSF AOHA PA ABYUZ PUAV ZVTLAOPUN LSZL.&#8221;)</p>
<p>(5.624457994579945,&#8221;IF I UNDERSTAND THE BASICS, MAYBE I CAN PUT ALL OF THEM INTO A BOX OR A CAN AND SHAKE IT SO BADLY THAT IT TURNS INTO SOMETHING ELSE.&#8221;)</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/syntaxfree.wordpress.com/51/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/syntaxfree.wordpress.com/51/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/syntaxfree.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/syntaxfree.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/syntaxfree.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/syntaxfree.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/syntaxfree.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/syntaxfree.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/syntaxfree.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/syntaxfree.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/syntaxfree.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/syntaxfree.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=51&subd=syntaxfree&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://syntaxfree.wordpress.com/2007/05/13/magic-caesar-autodecipher/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8aa2998eff18104553c29943cfd383cc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Macx</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple linear analysis of the performance of two algorithms.</title>
		<link>http://syntaxfree.wordpress.com/2007/05/04/lra/</link>
		<comments>http://syntaxfree.wordpress.com/2007/05/04/lra/#comments</comments>
		<pubDate>Fri, 04 May 2007 19:07:30 +0000</pubDate>
		<dc:creator>Macx</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://syntaxfree.wordpress.com/2007/05/04/lra/</guid>
		<description><![CDATA[I&#8217;ve mentioned over and over and over again that I&#8217;m not a programmer, but a econometrician. Today we put that to good use.
1. The problem
I can think of two ways of producing the list of divisors of a number:

divisors x = [ y &#124; y&#60;-[1..x], (gcd x y) == y]
fdivisors x = [ y &#124; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=46&subd=syntaxfree&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve mentioned over and over and over again that I&#8217;m not a programmer, but a econometrician. Today we put that to good use.</p>
<h3>1. The problem</h3>
<p>I can think of two ways of producing the list of divisors of a number:</p>
<p><code><br />
divisors x = [ y | y&lt;-[1..x], (gcd x y) == y]<br />
fdivisors x = [ y | y&lt;-[1..x], x `mod` y == 0]<br />
</code></p>
<p>Intuition would tell us the second one is faster, but is that really a fact?</p>
<h3>2. Generating data</h3>
<p> To test that, we devise two tests:</p>
<p><code><br />
test1p n = (n, sum $ map (length . divisors) [1..n])<br />
test2p n = (n, sum $ map (length . fdivisors) [1..n])<br />
</code></p>
<p>Now in  good old GNU R, I produce a list of random numbers between 50 and 10000 and paste them over my code.</p>
<p><code><br />
testdata = [3476,1856,3234,1080,369,2951,4930,4820,2270,2023,4613,3345,2252,2100,1187,643,3657,1493,4043,2439,4706,4885,2328,4294,4923,4427,4892,4147,4134,1215,586]<br />
</code></p>
<p>Now I&#8217;m going to engage in some code generation.</p>
<p><code><br />
produce = putStrLn $ concat $ map wrap testdata where<br />
                wrap n = "test1p "++show n ++ "\ntest2p "++show n ++ "\n"<br />
</code></p>
<p>I run <tt>produce</tt> in GHCi and paste the results on a text file. Next I add the following two lines to the beginning of said file:</p>
<p><code><br />
:l trigs.hs<br />
:set +s<br />
</code></p>
<p>where <tt>trigs.hs</tt> is the name of my Haskell code file. We save everything to <tt>produce.raw</tt> and on a shell window, I type</p>
<p><code><br />
ghci &lt; produce.raw<br />
</code></p>
<p>This will produce a few dozens of lines like</p>
<p><code><br />
*Trigs&gt; (3657,30578)<br />
(33.58 secs, 565482232 bytes)<br />
*Trigs&gt; (1493,11140)<br />
(8.95 secs, 291860752 bytes)<br />
*Trigs&gt; (1493,11140)<br />
(5.60 secs, 94533060 bytes)<br />
</code></p>
<p>After everything is said and done, a couple of regexes turns the results into CSV format. We add a line in the beginning naming the columns and switch back into GNU R.</p>
<h3>3. Loading and plotting data</h3>
<p>This line of R code will load our data into the system:<br />
<code><br />
data&lt;-read.table("~/repos/comparealgos.csv", header=TRUE, sep=",")<br />
</code></p>
<p>Let&#8217;s take some plots.</p>
<p><code><br />
plot(n, time)<br />
</code></p>
<p><img src="http://syntaxfree.files.wordpress.com/2007/05/div2.png"></p>
<p><code><br />
plot(n,bytes)<br />
</code></p>
<p><img src="http://syntaxfree.files.wordpress.com/2007/05/div3.png"></p>
<p>The intuitive story of (a) running time depending on the size of <tt>n</tt> and (b) the <tt>`mod`</tt> algorithm being faster than the <tt>gcd</tt> one seems to hold.  But let&#8217;s put numbers into this.</p>
<h4>4. Linear regression analysis</h4>
<p>In a nutshell, linear regresion analysis is about fitting data to an equation (possibly a system of multiple equations in more sophisticated models) and performing statistical tests of whether the fit means anything. The first model we&#8217;re going try to fit is the following:</p>
<p><img src='http://l.wordpress.com/latex.php?latex=%5Ctextrm%7Btime%7D+%3D+%5Calpha_0+%2B+%5Calpha_1+n+%2B+%5Calpha_2+n%5E2+%2B+%5Calpha_3+f+%2B+%5Cepsilon+&#038;bg=ffffff&#038;fg=000000&#038;s=2' alt='\textrm{time} = \alpha_0 + \alpha_1 n + \alpha_2 n^2 + \alpha_3 f + \epsilon ' title='\textrm{time} = \alpha_0 + \alpha_1 n + \alpha_2 n^2 + \alpha_3 f + \epsilon ' class='latex' /></p>
<p>where <img src='http://l.wordpress.com/latex.php?latex=f&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f' title='f' class='latex' /> is 0 for the gcd algorith and 1 for the mod algorithm, and <img src='http://l.wordpress.com/latex.php?latex=%5Cepsilon&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\epsilon' title='\epsilon' class='latex' /> accounts for serendipity.</p>
<p>Note the quadratic term: with this single term, we can both screen for more-than-linear and less-than-linear growth of <tt>time</tt> on <tt>n</tt>. Another way to look at this is to differentiate:</p>
<p><img src='http://l.wordpress.com/latex.php?latex=%5Cfrac%7B%5Cpartial+%5Ctextrm%7Btime%7D%7D%7B%5Cpartial+n%7D+%3D+%5Calpha_1+%2B+2+%5Calpha_2+n+&#038;bg=ffffff&#038;fg=000000&#038;s=2' alt='\frac{\partial \textrm{time}}{\partial n} = \alpha_1 + 2 \alpha_2 n ' title='\frac{\partial \textrm{time}}{\partial n} = \alpha_1 + 2 \alpha_2 n ' class='latex' /></p>
<p>As we see, <img src='http://l.wordpress.com/latex.php?latex=%5Calpha_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\alpha_1' title='\alpha_1' class='latex' /> is a constant effect of scale, while <img src='http://l.wordpress.com/latex.php?latex=%5Calpha_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\alpha_2' title='\alpha_2' class='latex' /> is an effect that varies on the size of n. If <img src='http://l.wordpress.com/latex.php?latex=%5Calpha_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\alpha_2' title='\alpha_2' class='latex' /> is negative, we have a smaller effect as n grows and vice-versa.</p>
<p>It&#8217;s also interesting to look at <img src='http://l.wordpress.com/latex.php?latex=f&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f' title='f' class='latex' />:</p>
<p><img src='http://l.wordpress.com/latex.php?latex=E+%5B+%5Ctextrm%7Btime%7D+%7C+%5Ctextrm%7Bgcd+algorithm%7D+%5D+%3D++%5Calpha_0+%2B+%5Calpha_1+n+%2B+%5Calpha_2+n%5E2+%2B+%5Cepsilon+&#038;bg=ffffff&#038;fg=000000&#038;s=2' alt='E [ \textrm{time} | \textrm{gcd algorithm} ] =  \alpha_0 + \alpha_1 n + \alpha_2 n^2 + \epsilon ' title='E [ \textrm{time} | \textrm{gcd algorithm} ] =  \alpha_0 + \alpha_1 n + \alpha_2 n^2 + \epsilon ' class='latex' /></p>
<p><img src='http://l.wordpress.com/latex.php?latex=E+%5B+%5Ctextrm%7Btime%7D+%7C+%5Ctextrm%7Bmod+algorithm%7D+%5D+%3D++%28%5Calpha_0+%2B+%5Calpha_3%29+%2B+%5Calpha_1+n+%2B+%5Calpha_2+n%5E2+%2B+%5Cepsilon+&#038;bg=ffffff&#038;fg=000000&#038;s=2' alt='E [ \textrm{time} | \textrm{mod algorithm} ] =  (\alpha_0 + \alpha_3) + \alpha_1 n + \alpha_2 n^2 + \epsilon ' title='E [ \textrm{time} | \textrm{mod algorithm} ] =  (\alpha_0 + \alpha_3) + \alpha_1 n + \alpha_2 n^2 + \epsilon ' class='latex' /></p>
<p>where <img src='http://l.wordpress.com/latex.php?latex=E%5B%5Ccdot%5D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='E[\cdot]' title='E[\cdot]' class='latex' /> is the expected value. In this model, the effect of changing algorithms is supposed to be constant for any <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' />.</p>
<p>Let&#8217;s run this on GNU R:</p>
<p><code><br />
model&lt;-lm(time~n+I(n^2)+f, data=data)<br />
summary(model)<br />
</code><br />
This will give us</p>
<p><code></p>
<pre>
Call:
lm(formula = time ~ n + I(n^2) + f, data = data)

Residuals:
     Min       1Q   Median       3Q      Max
-12.2097  -7.6267  -0.5312   7.7528  12.6358 

Coefficients:
              Estimate Std. Error t value Pr(&gt;|t|)
(Intercept)  1.190e+01  5.042e+00   2.361   0.0222 *
n           -9.796e-04  3.860e-03  -0.254   0.8007
I(n^2)       3.618e-06  6.534e-07   5.537 1.14e-06 ***
f           -2.265e+01  2.273e+00  -9.968 1.79e-13 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 8.35 on 50 degrees of freedom
Multiple R-Squared: 0.9386,	Adjusted R-squared: 0.9349
F-statistic: 254.9 on 3 and 50 DF,  p-value: &lt; 2.2e-16
</pre>
<p></code></p>
<p>The <tt>estimate</tt> column holds the value for the <img src='http://l.wordpress.com/latex.php?latex=alpha_i&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='alpha_i' title='alpha_i' class='latex' /> parameters defined on the equation above. The <tt>t value</tt> column is a measure of how far the parameter is from zero given its uncertainty. If the regression residuals follow a gaussian normal distribution, 1.96 (or -1.96) is a good critical value for considering the variable in question significant; in any case, values above 3 tend to indicate an important relationship.</p>
<p>The effect of <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' /> is apparently zero, but <img src='http://l.wordpress.com/latex.php?latex=n%5E2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n^2' title='n^2' class='latex' /> is significant and positive &#8212; which means the algorithm grows more-than-linearly on size. The effect of <img src='http://l.wordpress.com/latex.php?latex=f&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f' title='f' class='latex' /> is very strongly negative, which indicates the second algorithm really tends to be faster.</p>
<p>We can run, just for kicks, the same regression for memory usage. The algebraic analysis remains the same.</p>
<p><code></p>
<pre>
Call:
lm(formula = bytes ~ n + I(n^2) + f, data = data)

Residuals:
       Min         1Q     Median         3Q        Max
-624215565 -421792810   -1493863  425410175  622244685 

Coefficients:
              Estimate Std. Error t value Pr(&gt;|t|)
(Intercept)  6.368e+08  2.753e+08   2.313  0.02485 *
n           -2.654e+04  2.107e+05  -0.126  0.90027
I(n^2)       9.829e+01  3.567e+01   2.755  0.00816 **
f           -1.250e+09  1.241e+08 -10.075 1.25e-13 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 455900000 on 50 degrees of freedom
Multiple R-Squared: 0.8419,	Adjusted R-squared: 0.8324
F-statistic: 88.77 on 3 and 50 DF,  p-value: &lt; 2.2e-16
</pre>
<p></code></p>
<p>Compare the multiple <img src='http://l.wordpress.com/latex.php?latex=R%5E2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='R^2' title='R^2' class='latex' /> value between the two regressions. The <img src='http://l.wordpress.com/latex.php?latex=R%5E2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='R^2' title='R^2' class='latex' /> statistic measures how closely the model fits the data. One way to look at this is to affirm that apparently memory usage is also determined by something else we haven&#8217;t mentioned &#8212; this evidently being the size of the divisor list. </p>
<h3>5. A better model</h3>
<p>Let&#8217;s revise our equation.</p>
<p><img src='http://l.wordpress.com/latex.php?latex=%5Ctextrm%7Btime%7D+%3D+%5Calpha_0+%2B+%5Calpha_1+n+%2B+%5Calpha_2+n%5E2+%2B+%5Calpha_3+f+%2B+%5Calpha_4+f+%5Ctimes+n+%2B+%5Cepsilon+&#038;bg=ffffff&#038;fg=000000&#038;s=2' alt='\textrm{time} = \alpha_0 + \alpha_1 n + \alpha_2 n^2 + \alpha_3 f + \alpha_4 f \times n + \epsilon ' title='\textrm{time} = \alpha_0 + \alpha_1 n + \alpha_2 n^2 + \alpha_3 f + \alpha_4 f \times n + \epsilon ' class='latex' /></p>
<p>We&#8217;ve added an additional &#8220;interaction&#8221; term. To see what this means, let&#8217;s look at expected values again:</p>
<p><img src='http://l.wordpress.com/latex.php?latex=E+%5B+%5Ctextrm%7Btime%7D+%7C+%5Ctextrm%7Bgcd+algorithm%7D+%5D+%3D++%5Calpha_0+%2B+%5Calpha_1+n+%2B+%5Calpha_2+n%5E2+%2B+%5Cepsilon+&#038;bg=ffffff&#038;fg=000000&#038;s=2' alt='E [ \textrm{time} | \textrm{gcd algorithm} ] =  \alpha_0 + \alpha_1 n + \alpha_2 n^2 + \epsilon ' title='E [ \textrm{time} | \textrm{gcd algorithm} ] =  \alpha_0 + \alpha_1 n + \alpha_2 n^2 + \epsilon ' class='latex' /><br />
<img src='http://l.wordpress.com/latex.php?latex=E+%5B+%5Ctextrm%7Btime%7D+%7C+%5Ctextrm%7Bmod+algorithm%7D+%5D+%3D++%28%5Calpha_0+%2B+%5Calpha_3%29+%2B+%28%5Calpha_1%2B%5Calpha_4%29+n+%2B+%5Calpha_2+n%5E2+%2B+%5Cepsilon+&#038;bg=ffffff&#038;fg=000000&#038;s=2' alt='E [ \textrm{time} | \textrm{mod algorithm} ] =  (\alpha_0 + \alpha_3) + (\alpha_1+\alpha_4) n + \alpha_2 n^2 + \epsilon ' title='E [ \textrm{time} | \textrm{mod algorithm} ] =  (\alpha_0 + \alpha_3) + (\alpha_1+\alpha_4) n + \alpha_2 n^2 + \epsilon ' class='latex' /></p>
<p>In this new model, the effect of changing algorithms is allowed to vary with the size of <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' /> as well. Let&#8217;s estimate this model:</p>
<p><code></p>
<pre>
Call:
lm(formula = time ~ n + I(n^2) + f + f:n, data = data)

Residuals:
     Min       1Q   Median       3Q      Max
-4.56081 -1.30100  0.09815  1.67459  4.00706 

Coefficients:
              Estimate Std. Error t value Pr(&gt;|t|)
(Intercept) -5.622e+00  1.377e+00  -4.083 0.000164 ***
n            4.451e-03  9.600e-04   4.636 2.66e-05 ***
I(n^2)       3.618e-06  1.592e-07  22.723  &lt; 2e-16 ***
f            1.240e+01  1.362e+00   9.100 4.19e-12 ***
n:f         -1.086e-02  3.856e-04 -28.163  &lt; 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 2.035 on 49 degrees of freedom
Multiple R-Squared: 0.9964,	Adjusted R-squared: 0.9961
F-statistic:  3418 on 4 and 49 DF,  p-value: &lt; 2.2e-16
</pre>
<p></code></p>
<p>Now all the coefficients are indeed <em>very</em> significant, including the linear term on <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' />. This gives us the following formulas for predicting the running time of both algorithms on a given <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' />:</p>
<p><img src='http://l.wordpress.com/latex.php?latex=%5Cwidehat%7B+%5Ctextrm%7Btime%7D%7D_%7B%5Ctextrm%7Bgcd%7D%7D+%3D++-5.6+%2B+0.0045+n+%2B+0.0000036+n%5E2++&#038;bg=ffffff&#038;fg=000000&#038;s=2' alt='\widehat{ \textrm{time}}_{\textrm{gcd}} =  -5.6 + 0.0045 n + 0.0000036 n^2  ' title='\widehat{ \textrm{time}}_{\textrm{gcd}} =  -5.6 + 0.0045 n + 0.0000036 n^2  ' class='latex' /></p>
<p><img src='http://l.wordpress.com/latex.php?latex=%5Cwidehat%7B+%5Ctextrm%7Btime%7D%7D_%7B%5Ctextrm%7Bmod%7D%7D+%3D++6.77+-+0.0064+n+%2B+0.0000036+n%5E2++&#038;bg=ffffff&#038;fg=000000&#038;s=2' alt='\widehat{ \textrm{time}}_{\textrm{mod}} =  6.77 - 0.0064 n + 0.0000036 n^2  ' title='\widehat{ \textrm{time}}_{\textrm{mod}} =  6.77 - 0.0064 n + 0.0000036 n^2  ' class='latex' /></p>
<p>An interesting observation: the coefficient for <img src='http://l.wordpress.com/latex.php?latex=f&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f' title='f' class='latex' /> being positive means that the running time of the GCD algorithm <em>starts</em> lower; on the other hand, MOD will quickly outrun it (solve a simple inequality to find ranges of <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' /> if you&#8217;re so inclined). </p>
<h3>Conclusions</h3>
<p>I might return to this topic if it arises enough interest. For the time being, I tried keeping it short and sweet, even if it meant glossing over all the relevant theoretical details. Discussion is appreciated, etc. etc. Oh, and remember this all was run on an old G4 mac mini, on the interpreter (not compiled/optimized), all while browsing and IMing at the same time. Don&#8217;t just benchmark this on JRuby on your dual Opteron and say your language leaves my language biting the dust. </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/syntaxfree.wordpress.com/46/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/syntaxfree.wordpress.com/46/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/syntaxfree.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/syntaxfree.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/syntaxfree.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/syntaxfree.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/syntaxfree.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/syntaxfree.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/syntaxfree.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/syntaxfree.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/syntaxfree.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/syntaxfree.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=46&subd=syntaxfree&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://syntaxfree.wordpress.com/2007/05/04/lra/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8aa2998eff18104553c29943cfd383cc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Macx</media:title>
		</media:content>

		<media:content url="http://syntaxfree.files.wordpress.com/2007/05/div2.png" medium="image" />

		<media:content url="http://syntaxfree.files.wordpress.com/2007/05/div3.png" medium="image" />
	</item>
		<item>
		<title>A quick me-too and a suggestion</title>
		<link>http://syntaxfree.wordpress.com/2007/03/03/a-quick-me-too-and-a-suggestion/</link>
		<comments>http://syntaxfree.wordpress.com/2007/03/03/a-quick-me-too-and-a-suggestion/#comments</comments>
		<pubDate>Sat, 03 Mar 2007 11:50:32 +0000</pubDate>
		<dc:creator>Macx</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://syntaxfree.wordpress.com/2007/03/03/a-quick-me-too-and-a-suggestion/</guid>
		<description><![CDATA[First of all, let me get this out of my system:

Ok, now I have one more reason not to move out from WordPress.com
The LaTeX people should, by now, have a simple &#8220;web&#8221; version of LaTeX that can be easily installed by dropping files in your cgi-bin directory. The vast majority of people with hosting services [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=43&subd=syntaxfree&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>First of all, let me get this out of my system:</p>
<p><img src='http://l.wordpress.com/latex.php?latex=%5Cfrac%7B%5Cpartial+u%7D%7B%5Cpartial+q_1%7D+%3D+%5Ccdots+%3D+%5Cfrac%7B%5Cpartial+u%7D%7B%5Cpartial+q_n%7D&#038;bg=ffffff&#038;fg=000000&#038;s=3' alt='\frac{\partial u}{\partial q_1} = \cdots = \frac{\partial u}{\partial q_n}' title='\frac{\partial u}{\partial q_1} = \cdots = \frac{\partial u}{\partial q_n}' class='latex' /></p>
<p>Ok, now I have one more reason not to move out from WordPress.com</p>
<p>The LaTeX people should, by now, have a simple &#8220;web&#8221; version of LaTeX that can be easily installed by dropping files in your cgi-bin directory. The vast majority of people with hosting services that won&#8217;t grant them shell access can&#8217;t ever have LaTeX because the current distributions are so desktop-oriented.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/syntaxfree.wordpress.com/43/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/syntaxfree.wordpress.com/43/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/syntaxfree.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/syntaxfree.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/syntaxfree.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/syntaxfree.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/syntaxfree.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/syntaxfree.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/syntaxfree.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/syntaxfree.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/syntaxfree.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/syntaxfree.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=43&subd=syntaxfree&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://syntaxfree.wordpress.com/2007/03/03/a-quick-me-too-and-a-suggestion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8aa2998eff18104553c29943cfd383cc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Macx</media:title>
		</media:content>
	</item>
		<item>
		<title>A slightly better function-DOT dsl</title>
		<link>http://syntaxfree.wordpress.com/2007/02/24/a-slightly-better-function-dot-dsl/</link>
		<comments>http://syntaxfree.wordpress.com/2007/02/24/a-slightly-better-function-dot-dsl/#comments</comments>
		<pubDate>Sat, 24 Feb 2007 16:58:12 +0000</pubDate>
		<dc:creator>Macx</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://syntaxfree.wordpress.com/2007/02/24/a-slightly-better-function-dot-dsl/</guid>
		<description><![CDATA[In some of the graphs in Bycicling for Collatz (the divisibility graph with lots of arrows and the collatz one with 1, 2 and 4 highlighted) we manipulated the Haskell-generated graph either in the DOT file source or directly in the Graphviz GUI.  The structure itself was somewhat confusing, too; the Dot class never [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=42&subd=syntaxfree&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In some of the graphs in <a href="http://syntaxfree.wordpress.com/2007/02/22/bycicling-for-collatz/">Bycicling for Collatz</a> (the divisibility graph with lots of arrows and the collatz one with 1, 2 and 4 highlighted) we manipulated the Haskell-generated graph either in the DOT file source or directly in the Graphviz GUI.  The structure itself was somewhat confusing, too; the Dot class never managed to justify itself. Here&#8217;s a slightly cleaner version of that code to play with:</p>
<h1>bikes.hs</h1>
<div style="text-align:left;color:#000000;background-color:#d7ffcc;border:solid black 1px;overflow:auto;padding:0.5em 1em;"><span style="color:#881350;">module</span> Bikes <span style="color:#881350;">where</span></p>
<p><span style="color:#881350;">data</span> Arr a = a :-&gt; a<br />
instance Functor Arr <span style="color:#881350;">where</span> fmap f (x:-&gt;y) = f &nbsp;x :-&gt; f y<br />
instance (Show a) =&gt; Show (Arr a) <span style="color:#881350;">where</span> show (x:-&gt;y) = show x ++ <span style="color:#760f15;">&quot; -&gt; &quot;</span> ++ show y <br />
arr f = (\x-&gt; x :-&gt; f x)<br />
rra f = (\x-&gt; f x :-&gt; x)<br />
<span style="color:#881350;">data</span> YellowGraph a = YG {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;why <span style="color:#000088;">::</span> (a-&gt;Bool),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;func <span style="color:#000088;">::</span> (a <span style="color:#000088;">-&gt;</span> a),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;space <span style="color:#000088;">::</span> [a]} <br />
instance (Show a) =&gt; Show &nbsp;(YellowGraph a) <span style="color:#881350;">where</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;show xs = &nbsp;finalDot $ (toColorList xs) ++ (toArrList xs) <span style="color:#881350;">where</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;runGraph xs = (map (arr (func xs)) (space xs))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filterGraph xs = (filter (why xs) (space xs))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;toArrList xs &nbsp;= unlineAppend <span style="color:#760f15;">&quot;;&quot;</span> &nbsp;(runGraph xs)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;toColorList &nbsp;xs = unlineAppend <span style="color:#760f15;">&quot; [color = \&quot;yellow\&quot;, style=\&quot;filled\&quot;, shape=\&quot;diamond\&quot;];&quot;</span> (filterGraph xs)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;finalDot x = <span style="color:#760f15;">&quot;digraph untitled {&quot;</span> ++ x ++ <span style="color:#760f15;">&quot;}&quot;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unlineAppend d &nbsp;= unlines . map ((++d) . show) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
graph f xs = YG { why = const False, func = f, space = xs}</p>
<p>jane = YG { why = even, func = (flip div <span style="color:#0000ff;">3</span>), space = [<span style="color:#0000ff;">1..80</span>]}</div>
<div style="text-align:center;font-size:10px;color:#555;font-family:sanserif;">
</div>
<p>The <strong>why</strong> parameter passed to the data constructor when you&#8217;re using the full syntax as in the <strong>jane</strong> example is a predicate that decides whether or not color a node yellow. Simple, color-less graphs can be produced with the auxiliary function <strong>graph</strong>. </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/syntaxfree.wordpress.com/42/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/syntaxfree.wordpress.com/42/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/syntaxfree.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/syntaxfree.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/syntaxfree.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/syntaxfree.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/syntaxfree.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/syntaxfree.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/syntaxfree.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/syntaxfree.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/syntaxfree.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/syntaxfree.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=42&subd=syntaxfree&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://syntaxfree.wordpress.com/2007/02/24/a-slightly-better-function-dot-dsl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8aa2998eff18104553c29943cfd383cc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Macx</media:title>
		</media:content>
	</item>
		<item>
		<title>Bicycling for Collatz</title>
		<link>http://syntaxfree.wordpress.com/2007/02/22/bycicling-for-collatz/</link>
		<comments>http://syntaxfree.wordpress.com/2007/02/22/bycicling-for-collatz/#comments</comments>
		<pubDate>Thu, 22 Feb 2007 10:44:53 +0000</pubDate>
		<dc:creator>Macx</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://syntaxfree.wordpress.com/2007/02/22/bycicling-for-collatz/</guid>
		<description><![CDATA[
Q: How many people with ADD does it take to change a lightbulb?
A: HEY! Let&#8217;s ride bikes!


module Bikes where

Graphviz is fun. Graphviz is fair. You may already have one. You may already be there:

data Arr a = a :-&#62; a

Graphviz plots graphs from .DOT files consisting of remarkably simple syntax:

instance (Show a) =&#62; Show (Arr [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=35&subd=syntaxfree&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><blockquote><p>
Q: How many people with ADD does it take to change a lightbulb?<br />
A: HEY! Let&#8217;s ride bikes!
</p></blockquote>
<p><code><br />
module Bikes where<br />
</code></p>
<p>Graphviz is fun. Graphviz is fair. You may already have one. You may already be there:</p>
<p><code><br />
data Arr a = a :-&gt; a<br />
</code></p>
<p>Graphviz plots graphs from .DOT files consisting of remarkably simple syntax:</p>
<p><code><br />
instance (Show a) =&gt; Show (Arr a) where show (x:-&gt;y) = show x ++ " -&gt; " ++ show y<br />
class (Show a) =&gt; (Dot a) where<br />
        dot :: [a] -&gt; String<br />
        dot = (++"}") . ("digraph untitled {"++) . unlines . map ((++";") . show)<br />
instance (Show a) =&gt; Dot (Arr a)<br />
</code></p>
<p>One fun thing we can do with it is plotting graphs of integer-valued functions:</p>
<p><code><br />
arr f = (\x-&gt; x :-&gt; f x)<br />
rra f = (\x-&gt; f x :-&gt; x)<br />
</code></p>
<p>Let&#8217;s see what a simple invertible function looks like:</p>
<p><code><br />
t2 = dot $ map (arr (*2)) [0..40]<br />
</code></p>
<p><a href="http://syntaxfree.files.wordpress.com/2007/02/t2.jpg"><img src="http://syntaxfree.files.wordpress.com/2007/02/t2.jpg"></a></p>
<p>Clearly there&#8217;s one and only one way to connect any given two nodes &#8212; which is what invertibility means. But let&#8217;s look at something fun now; say, the co-totient function. There&#8217;s a closed-form equation for this, but why not go full ape declarative?</p>
<p><code><br />
totient x = x - (length $  [n | n&lt;-[1..x], coprimes n x]) where coprimes a b = (gcd a b) == 1<br />
t3 = dot $ map (arr totient) [1..100]<br />
</code></p>
<p><a href="http://syntaxfree.files.wordpress.com/2007/02/co-tot.jpg"><img src="http://syntaxfree.files.wordpress.com/2007/02/co-tot.jpg" width="450" height="180"></p>
<p>(Click to see full-size picture)<br />
</a></p>
<p>The first hierarchy line contains the prime numbers; their co-totient is always 1. These numbers are connected to numbers whose co-totient they are; from that graph you can find the co-totient of any number by looking at which number it&#8217;s connected to. At first glance it looks pretty tree-like, but it suffices to chase the series of powers of two to see it isn&#8217;t.</p>
<p>Now, being that the totient is the quantity of numbers &#8220;strange&#8221; to a number (in the sense their only common divisor is 1) and the co-totient is precisely a number minus its totient, higher co-totients seem to indicate a more &#8220;composite&#8221; structure. That&#8217;s not clearly represented by graph hierarchy, of course. So we try a different representation of compositeness in integers:</p>
<p><code><br />
t4 = dot $ filter (\(x:-&gt;y) -&gt; y /=1 &amp;&amp; x/=y ) $ concat $ map (\y-&gt;(map (arr (gcd y)) [2..32])) [2..32]<br />
</code></p>
<p>This will connect all numbers that divide each other by as many arrows as there are ways to divide it:</p>
<p><a href="http://syntaxfree.files.wordpress.com/2007/02/divide32.jpg"><img src="http://syntaxfree.files.wordpress.com/2007/02/div32-thumb.jpg"></p>
<p>Click here to see full image<br />
</a></p>
<p>That makes for a smashing bedroom poster. </p>
<p>Finally, as hopelessly amateur mathematicians we are, we just can&#8217;t resist poking the Collatz function!</p>
<p><code><br />
t = dot $ map (rra (\x-&gt;if (odd x) then 3*x+1 else x `div` 2)) [1..384]<br />
</code></p>
<p>I&#8217;ve plotted Collatz graphs as far as 15000. But let&#8217;s keep it to manageable sizes; you can later experiment at home and see trust me that larger graphs keep the structure contained in this graph &#8212; there are relatively very few ways to get into the &#8220;main Collatz stream&#8221; down to 4-2-1 and most numbers are stuck in two-house citadels of their own, with a few managing to form their own substreams that sometimes even manage to join the main Collatz &#8220;stream&#8221;:</p>
<p><a href='http://syntaxfree.files.wordpress.com/2007/02/smacol.jpg' title='smacol.jpg'><img src="http://syntaxfree.files.wordpress.com/2007/02/sma-thumb.jpg"></p>
<p>Abandon all hope ye who enter here</a></p>
<p>Yes, I know, I should be working in PFP and all, but when a boy&#8217;s mind is overcome with newfound love, he must clutch at any tiny window of intellectual focus he occasionally comes across by as his brain walks through the shadows of love.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/syntaxfree.wordpress.com/35/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/syntaxfree.wordpress.com/35/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/syntaxfree.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/syntaxfree.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/syntaxfree.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/syntaxfree.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/syntaxfree.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/syntaxfree.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/syntaxfree.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/syntaxfree.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/syntaxfree.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/syntaxfree.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=35&subd=syntaxfree&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://syntaxfree.wordpress.com/2007/02/22/bycicling-for-collatz/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8aa2998eff18104553c29943cfd383cc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Macx</media:title>
		</media:content>

		<media:content url="http://syntaxfree.files.wordpress.com/2007/02/t2.jpg" medium="image" />

		<media:content url="http://syntaxfree.files.wordpress.com/2007/02/co-tot.jpg" medium="image" />

		<media:content url="http://syntaxfree.files.wordpress.com/2007/02/div32-thumb.jpg" medium="image" />

		<media:content url="http://syntaxfree.files.wordpress.com/2007/02/sma-thumb.jpg" medium="image" />
	</item>
		<item>
		<title>The Gee-Whiz Monad (I)</title>
		<link>http://syntaxfree.wordpress.com/2007/02/19/the-gee-whiz-monad-i/</link>
		<comments>http://syntaxfree.wordpress.com/2007/02/19/the-gee-whiz-monad-i/#comments</comments>
		<pubDate>Mon, 19 Feb 2007 01:23:57 +0000</pubDate>
		<dc:creator>Macx</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://syntaxfree.wordpress.com/2007/02/19/the-gee-whiz-monad-i/</guid>
		<description><![CDATA[[] is really the gee-whiz monad. Haskell code that prints *all the five-number combinations of integers in [-5..5]:

mapM (\x-&#62;[x+i &#124; i&#60;-[-5..5]]) [1..5]

No, really, try it. This has to qualify as the &#8220;most surprisingly long output&#8221; line of code in all of computer programming. 
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=34&subd=syntaxfree&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>[] is really the gee-whiz monad. Haskell code that prints *all the five-number combinations of integers in [-5..5]:</p>
<p><code><br />
mapM (\x-&gt;[x+i | i&lt;-[-5..5]]) [1..5]<br />
</code></p>
<p>No, really, try it. This has to qualify as the &#8220;most surprisingly long output&#8221; line of code in all of computer programming. </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/syntaxfree.wordpress.com/34/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/syntaxfree.wordpress.com/34/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/syntaxfree.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/syntaxfree.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/syntaxfree.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/syntaxfree.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/syntaxfree.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/syntaxfree.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/syntaxfree.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/syntaxfree.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/syntaxfree.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/syntaxfree.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=syntaxfree.wordpress.com&blog=607762&post=34&subd=syntaxfree&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://syntaxfree.wordpress.com/2007/02/19/the-gee-whiz-monad-i/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8aa2998eff18104553c29943cfd383cc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Macx</media:title>
		</media:content>
	</item>
	</channel>
</rss>