<?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>Haskell Rascal</title>
	<atom:link href="http://haskellrascal.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://haskellrascal.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sat, 24 Apr 2010 19:05:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='haskellrascal.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Haskell Rascal</title>
		<link>http://haskellrascal.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://haskellrascal.wordpress.com/osd.xml" title="Haskell Rascal" />
	<atom:link rel='hub' href='http://haskellrascal.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Euler Down</title>
		<link>http://haskellrascal.wordpress.com/2010/04/24/euler-down/</link>
		<comments>http://haskellrascal.wordpress.com/2010/04/24/euler-down/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 18:18:38 +0000</pubDate>
		<dc:creator>fwhaslam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[do]]></category>
		<category><![CDATA[do block]]></category>
		<category><![CDATA[Euler]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[matchers]]></category>
		<category><![CDATA[primes]]></category>
		<category><![CDATA[project euler]]></category>

		<guid isPermaLink="false">http://haskellrascal.wordpress.com/?p=66</guid>
		<description><![CDATA[Euler, problem #3: What is the largest prime factor of the number 600851475143 ? main = do { &#160; print (factors 1300); -- demonstrate factor lists &#160; print (last (factors 600851475143)) } factors :: Integer -&#62; [Integer] factors num = factorise num 2 My solution is to produce a stream of factors, starting with the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=66&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Euler, problem #3:  What is the largest prime factor of the number 600851475143 ?<br />
<code><br />
main = do {<br />
 &nbsp; print (factors 1300);  -- demonstrate factor lists<br />
 &nbsp; print (last (factors 600851475143))<br />
}</p>
<p>factors :: Integer -&gt; [Integer]<br />
factors num = factorise num 2<br />
</code></p>
<p>My solution is to produce a stream of factors, starting with the lowest.  As you can see, I hand off from &#8216;factors num&#8217; to &#8216;factorise num 2&#8242;.  In order to test different factor values I need to include them (the factor values) in the method.  I am using the value 2 (or &#8216;factor&#8217; below) as a primitive state object.  It only ever contains one value.  It is incremented and passed down to further calls to factorise, and it is not returned.  BUT it is definitely a state.</p>
<p>Before I would use multiple definitions for a method, with pattern matching to decide which definition would be used.  The &#8216;pipe&#8217; method below is the exact same thing, we just dont have to type &#8216;factorise num factor&#8217; two extra times.  And we don&#8217;t have to define num+factor for our conditionals.  Also, the pipe visually associates all the definitions, making it more readable.  </p>
<p>The matchers present a test &#8211; some pattern or condition &#8211; followed by a definition (stuff after the equals).  The last matcher is the keyword &#8216;otherwise&#8217;, which will match all the leftovers.<br />
<code><br />
factorise :: Integer -&gt; Integer -&gt; [Integer]<br />
factorise num factor<br />
 &nbsp; | factor &gt; num = []<br />
 &nbsp; | (mod num factor == 0) = factor : factorise (div num factor) factor<br />
 &nbsp; | otherwise = factorise num (factor+1)<br />
</code></p>
<p>This method returns a list of integers.  When the factor is greater than the num, it returns an empty list.  When the factor moduloes to zero, then we put it in the front of the list, and try again.  Finally, if the factor moduloes to non-zero, we need to try a different factor &#8211; so increment the current factor.</p>
<p>This is not an efficient method.  The best improvement would be to replace the (factor+1) with something like &#8216;(nextPrime factor)&#8217;.  We don&#8217;t need every single number, we should be able to skip just to the primes.</p>
<p>So I guess thats my next challenge, to create a state object that skips to the primes.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/haskellrascal.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/haskellrascal.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/haskellrascal.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/haskellrascal.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/haskellrascal.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/haskellrascal.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/haskellrascal.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/haskellrascal.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/haskellrascal.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/haskellrascal.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/haskellrascal.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/haskellrascal.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/haskellrascal.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/haskellrascal.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=66&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://haskellrascal.wordpress.com/2010/04/24/euler-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b490a83b92facdeaf7535fa6915f7215?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fwhaslam</media:title>
		</media:content>
	</item>
		<item>
		<title>Euler Up</title>
		<link>http://haskellrascal.wordpress.com/2010/04/22/euler-up/</link>
		<comments>http://haskellrascal.wordpress.com/2010/04/22/euler-up/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 03:35:41 +0000</pubDate>
		<dc:creator>fwhaslam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[Euler]]></category>
		<category><![CDATA[fibonnaci]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[project euler]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[sequences]]></category>
		<category><![CDATA[tuple bubble]]></category>
		<category><![CDATA[tuples]]></category>

		<guid isPermaLink="false">http://haskellrascal.wordpress.com/?p=55</guid>
		<description><![CDATA[My goal du jour is to solve some Euler problems.  I&#8217;ve been through this once before with scala, so the problems themselves are clear.  Just doing the same thing with haskell is in question. I am tackling euler #2:  http://projecteuler.net/index.php?section=problems&#38;id=2 Sum up all even values in the fibonacci sequence below 4 million. Here is the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=55&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My goal du jour is to solve some Euler problems.  I&#8217;ve been through this once before with <strong>scala</strong>, so the problems themselves are clear.  Just doing the same thing with <strong>haskell</strong> is in question.</p>
<p>I am tackling euler #2:  <a href="http://projecteuler.net/index.php?section=problems&amp;id=2">http://projecteuler.net/index.php?section=problems&amp;id=2</a> Sum up all even values in the fibonacci sequence below 4 million.</p>
<p>Here is the core of my solution, a sequence that produces fibonacci numbers.  I wish I had a &#8216;zipWith&#8217; function in <strong>scala</strong>; it sure cleans up the the &#8216;<strong><em>tuple bubble&#8217;</em></strong> problem (see the end of this post).</p>
<ul>
<li>fibs = 0 : 1 : zipWith (+) fibs (tail fibs)</li>
</ul>
<p>Here is how it works:  The first two values are defined zero and one.   All subsequent values are produced by a sequence generated by zipWith().  This function takes two sequences and produces a third sequence.  In this case the two inputs are the fibonacci numbers <em><strong>and</strong></em> the fibonacci numbers SKIPPING the first element (=tail).  We apply the plus operation to each pair of values from the two sequences.  The result is that zipWith() produces first (0+1) &#8230; then (1+1) &#8230; then (1+2) &#8230;  and so on.  This wonder works due to the magic of lazy loading (as in, don&#8217;t do no work until you need a number).</p>
<p>The rest of the solution is fairly prosaic.  Take all fibonaccis beneath some limit:</p>
<ul>
<li>fiblist limit = takeWhile (&lt;limit) fibs</li>
</ul>
<div id="_mcePaste">Take the stream of fibonaccis, filter out the evens:</div>
<div>
<ul>
<li>evenlist limit = filter even ( fiblist limit )</li>
</ul>
</div>
<p>Sum up all values in the fibonacci stream:</p>
<ul>
<li>solve limit = foldr (+) 0 (evenlist limit)</li>
</ul>
<p>Print the solution:</p>
<div>
<ul>
<li>main = print ( solve 4000000 )</li>
</ul>
</div>
<p>Of course the commands are ass-backwards from my euler-002.hs file.  Main comes first, and the fibs definition is last.  And we could pump most of it into a single line &#8230; but who can read that?</p>
<p>What is this <em><strong>&#8216;tuple bubble&#8217;</strong></em>?   In <strong>scala</strong> the closest thing to zipWith() is the zip().  You can combine two streams, but instead of applying a function to paired elements, it produces a stream of tuples.  A tuple is an object, so it uses up memory and processing power.  Rudimentary benchmarking in <strong>scala</strong> show that traversing two arrays and applying a function is up to 40 times faster than producing a tuple and then processing it.</p>
<p>So I think my next mini-project will be to build a zipWith() for <strong>scala</strong>.  Meet me over in my other blog to see the results.<br />
<a href="http://fwhaslam.wordpress.com/2010/04/21/zipwith-challenge/">http://fwhaslam.wordpress.com/2010/04/21/zipwith-challenge/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/haskellrascal.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/haskellrascal.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/haskellrascal.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/haskellrascal.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/haskellrascal.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/haskellrascal.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/haskellrascal.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/haskellrascal.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/haskellrascal.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/haskellrascal.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/haskellrascal.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/haskellrascal.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/haskellrascal.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/haskellrascal.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=55&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://haskellrascal.wordpress.com/2010/04/22/euler-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b490a83b92facdeaf7535fa6915f7215?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fwhaslam</media:title>
		</media:content>
	</item>
		<item>
		<title>Colon Scope</title>
		<link>http://haskellrascal.wordpress.com/2010/03/13/colon-scope/</link>
		<comments>http://haskellrascal.wordpress.com/2010/03/13/colon-scope/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 04:36:15 +0000</pubDate>
		<dc:creator>fwhaslam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[declarations]]></category>
		<category><![CDATA[double colon]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[magical]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[types]]></category>

		<guid isPermaLink="false">http://haskellrascal.wordpress.com/?p=46</guid>
		<description><![CDATA[Lets talk a little bit about declaring functions. rx :: [a] -&#62; a -&#62; [a] rx [] r = [r] rx (x:xs) r = x : rx xs r It is not entirely obvious what the various bits are, so let&#8217;s use some long names to make it more readable. myInfix :: [something] -&#62; something [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=46&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Lets talk a little bit about declaring functions.</p>
<blockquote><p>rx :: [a] -&gt; a -&gt; [a]<br />
rx [] r = [r]<br />
rx (x:xs) r = x : rx xs r</p></blockquote>
<p>It is not entirely obvious what the various bits are, so let&#8217;s use some long names to make it more readable.</p>
<blockquote><p>myInfix :: [something] -&gt; something -&gt; [something]<br />
myInfix [] atEnd = [ atEnd ]<br />
myInfix (listHead:listTail) atEnd = listHead : ( myInfix listTail atEnd )</p></blockquote>
<p><span style="font-weight:bold;">Something magical and weird</span> is happening at the double colon ::  We are declaring the type for our method <em>myInfix</em>.  If this were another language, we would think about the type declaration as:  My Function takes a List and an Element, then produces another List.  If that were the case, we would expect to see the following:</p>
<ul>
<li>myInfix :: ( [something] , something) -&gt; [something]</li>
</ul>
<p>But that conception is false.  Instead, we are saying:  My Function takes a List, then produces another (invisible) Function which takes an Element, which in turn produces a List.  So we can conceptually group that as follows:</p>
<ul>
<li>( (myInfix :: [something]) -&gt; something ) -&gt; [something]           <span style="font-style:italic;">&#8211; but do not actually group this way, as it won&#8217;t compile</span></li>
</ul>
<p><span style="font-weight:bold;">Next to consider</span> ::  &#8217;<em>something</em>&#8216; is not an actual type.  Instead it represents any type that we decide to use with the function.  The fact that &#8216;<span style="font-style:italic;">something</span>&#8216; is mentioned in three places <span style="font-style:italic;">does</span> create a constraint.  We must use and expect the same type in <span style="font-style:italic;">each</span> of the three places.  So the following examples work:</p>
<ul>
<li>myInfix [1,2] 6    produces [1,2,6]</li>
<li>myInfix &#8220;hi&#8221; &#8216;o&#8217;   produces &#8220;hio&#8221;</li>
</ul>
<p>But the following fail:</p>
<ul>
<li>myInfix [1,2] &#8216;n&#8217;</li>
<li>myInfix[False,True] 8</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/haskellrascal.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/haskellrascal.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/haskellrascal.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/haskellrascal.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/haskellrascal.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/haskellrascal.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/haskellrascal.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/haskellrascal.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/haskellrascal.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/haskellrascal.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/haskellrascal.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/haskellrascal.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/haskellrascal.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/haskellrascal.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=46&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://haskellrascal.wordpress.com/2010/03/13/colon-scope/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b490a83b92facdeaf7535fa6915f7215?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fwhaslam</media:title>
		</media:content>
	</item>
		<item>
		<title>The Fix is In</title>
		<link>http://haskellrascal.wordpress.com/2010/03/12/the-fix-is-in/</link>
		<comments>http://haskellrascal.wordpress.com/2010/03/12/the-fix-is-in/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 05:49:40 +0000</pubDate>
		<dc:creator>fwhaslam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[bums]]></category>
		<category><![CDATA[concat]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[infix]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://haskellrascal.wordpress.com/?p=40</guid>
		<description><![CDATA[So I&#8217;ve been playing with the infix operator.  Note that haskell has functions and operators and other syntax stuff that I&#8217;m not paying attention to yet.  Operators seem to exist at the compiler level; while Functions are defined in some module and are built out of operators and other syntax stuff.   Operators include things like [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=40&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve been playing with the infix operator.  Note that haskell has functions and operators and other syntax stuff that I&#8217;m not paying attention to yet.  Operators seem to exist at the compiler level; while Functions are defined in some module and are built out of operators and other syntax stuff.   Operators include things like add(+), subtract(-), multiply(*), divide(/), and power(^); while Functions include things like head, tail and last.</p>
<p>Let&#8217;s talk about two of the list operators:  infix (:)  and concat(++).  Here are some examples of them at work:</p>
<ul>
<li>1:[]   produces   [1]</li>
<li>1:2:[]   produces  [1,2]</li>
<li>1:[2..4]   produces  [1,2,3,4]</li>
<li>&#8216;a&#8217;:['b','c']   produces  &#8221;abc&#8221;   (which is equivalent to ['a','b','c'])</li>
<li>[1,2]  ++ [3,4]   produces   [1,2,3,4]</li>
<li>[]  ++  [5,3,1]   produces  [5,3,1]</li>
<li>&#8220;hi&#8221; ++ &#8220;there&#8221;   produces  &#8221;hithere&#8221;</li>
</ul>
<p>Here are some examples that produce errors:</p>
<ul>
<li>1:2</li>
<li>[]:1</li>
<li>1 ++ [2,3]</li>
<li>[5,4,3] ++ 8</li>
<li>1:&#8221;hi&#8221;</li>
<li>[1,2]++&#8221;there&#8221;</li>
</ul>
<p>So, infix only works with an element of some type and a list of the same type.   While concat only works with two lists of the same type.</p>
<p>I then went looking for an operator to handle the <em>&#8216;element on the right&#8217;</em> case for infix, but I couldn&#8217;t find one.  So, I made the following (which ONLY handles the case of list followed by element):</p>
<blockquote>
<div id="_mcePaste">rx :: [a] -&gt; a -&gt; [a]</div>
<div id="_mcePaste">rx [] r = [r]</div>
<div id="_mcePaste">rx (x:xs) r = x : rx xs r</div>
</blockquote>
<div>I tear apart a list one element at a time until I hit the empty list, then I reconstruct it backwards.  Tada!</div>
<div>
<ul>
<li>rx [1,2,3] 8   produces [1,2,3,8]</li>
<li>[2,3]  `rx` 1   produces [2,3,1]</li>
<li>rx &#8220;hi&#8221; &#8216;o&#8217;   produces &#8220;hio&#8221;</li>
<li>rx [3,6] -1   produces an error <em>= No instance for (Num (t -&gt; [t]))     arising from a use of `-&#8217; at &#8230;</em></li>
<li>rx [3,6] (-1)   produces [3,6,-1]</li>
</ul>
</div>
<p>The error results from providing the minus operator as an input to my function.   While it looks like it is attached to the one, it is actually parsed as a separate element.  Including the parentheses forces the subtract one to resolve into minus one.</p>
<p>Oh, and here is the mo&#8217; betterer implementation</p>
<ul>
<li>let rx list right = list ++ [right]</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/haskellrascal.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/haskellrascal.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/haskellrascal.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/haskellrascal.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/haskellrascal.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/haskellrascal.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/haskellrascal.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/haskellrascal.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/haskellrascal.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/haskellrascal.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/haskellrascal.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/haskellrascal.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/haskellrascal.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/haskellrascal.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=40&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://haskellrascal.wordpress.com/2010/03/12/the-fix-is-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b490a83b92facdeaf7535fa6915f7215?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fwhaslam</media:title>
		</media:content>
	</item>
		<item>
		<title>Out of Sorts</title>
		<link>http://haskellrascal.wordpress.com/2010/03/10/out-of-sorts/</link>
		<comments>http://haskellrascal.wordpress.com/2010/03/10/out-of-sorts/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 15:30:30 +0000</pubDate>
		<dc:creator>fwhaslam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[list comprehension]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://haskellrascal.wordpress.com/?p=35</guid>
		<description><![CDATA[My next goal is to implement some sorting algorithms.  As a first step I am having a look at sorting examples.  Here is an implementation of the popular quicksort: quicksort [] = [] quicksort (x:xs) =  [y&#124;y&#60;-xs,y&#60;x] ++ [x] ++ [y&#124;y&#60;-xs,y&#62;x] There is a log going on in these two lines.  It took me a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=35&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My next goal is to implement some sorting algorithms.  As a first step I am having a look at sorting examples.  Here is an implementation of the popular quicksort:</p>
<blockquote><p>quicksort [] = []<br />
quicksort (x:xs) =  [y|y&lt;-xs,y&lt;x] ++ [x] ++ [y|y&lt;-xs,y&gt;x]</p></blockquote>
<p>There is a log going on in these two lines.  It took me a while to sort everything out.  Let&#8217;s start at the top and work our way down:</p>
<ul>
<li>quicksort [] = []</li>
</ul>
<p>The first line simply states that sorting an empty list will produce an empty list.  Pretty intuitive.</p>
<ul>
<li>quicksort (x:xs) = &#8230;</li>
</ul>
<p>The special notation (x:sx) will match a list, and break it into two variables:   x = head(list)  xs = tail(list) .   So internally the values x and xs become &#8230;</p>
<ul>
<li>quicksort [1,2,3]</li>
<li>x = 1      and     xs = [2,3]</li>
</ul>
<p>Not so intuitive, but sensible.  The next statement can be broken into three parts:</p>
<ul>
<li><em>[y|y&lt;-xs,y&lt;x] ++ [x] ++ [y|y&lt;-xs,y&gt;x]</em></li>
<li>A list of everything in <em>xs</em> less than <em>x</em> ++    a list which only contains <em>x</em> ++   A list of everything in <em>xs</em> greater than <em>x</em></li>
</ul>
<p>The connecting ++ values will append lists together.  This is why the central piece is a <em>list</em> containing <em>x</em>.  The outer pieces are &#8216;list comprehensions&#8217;.  They resemble mathematical expressions, but are not identical.</p>
<ul>
<li><em>[ y | y&lt;-xs, y&lt;x ]</em></li>
<li>a list of<em> y</em> such that    <em>y</em> is a member of <em>xs</em> and    <em>y</em> is less than <em>x</em></li>
</ul>
<p>My interpretation of <em>&lt;-</em> as <em>&#8216;member of&#8217;</em> is not really accurate.  In haskell a better interpretation would be <em>&#8216;each member in turn&#8217;</em>.  The difference was obvious when I did the following experiment:</p>
<ul>
<li>[ y | y &lt;- [1,2,3] ,   y&lt;-[2,3,4]  ]</li>
<li>Expected Math Solution = [2,3]</li>
<li>Haskell produces [2,3,4,2,3,4,2,3,4]    (why?  we traversed <em>xs</em> from 1 to 3, then for each element also traversed the list 2,3,4 producing 9 elements)</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/haskellrascal.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/haskellrascal.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/haskellrascal.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/haskellrascal.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/haskellrascal.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/haskellrascal.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/haskellrascal.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/haskellrascal.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/haskellrascal.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/haskellrascal.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/haskellrascal.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/haskellrascal.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/haskellrascal.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/haskellrascal.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=35&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://haskellrascal.wordpress.com/2010/03/10/out-of-sorts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b490a83b92facdeaf7535fa6915f7215?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fwhaslam</media:title>
		</media:content>
	</item>
		<item>
		<title>Compile Post</title>
		<link>http://haskellrascal.wordpress.com/2010/03/06/compile-post/</link>
		<comments>http://haskellrascal.wordpress.com/2010/03/06/compile-post/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 21:41:01 +0000</pubDate>
		<dc:creator>fwhaslam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[ghc]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[IO Monad]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[run]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://haskellrascal.wordpress.com/?p=24</guid>
		<description><![CDATA[You can compile your *.hs files using the ghc utility.  Your file should define some module; but you can use the default module Main with no declarations.  You simply need to create a main function which returns an IO Monad: main = print( &#8220;Hello World&#8221; ) Compile and run as follows: ghc my-haskell-file.hs ./a.out For [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=24&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You can compile your *.hs files using the <strong>ghc</strong> utility.  Your file should define some module; but you can use the default module <strong>Main</strong> with no declarations.  You simply need to create a <strong>main</strong> function which returns an IO Monad:</p>
<ul>
<li>main = print( &#8220;Hello World&#8221; )</li>
</ul>
<p>Compile and run as follows:</p>
<ul>
<li>ghc my-haskell-file.hs</li>
<li>./a.out</li>
</ul>
<p>For all the stuff I am not bothering with right now, do this:</p>
<ul>
<li>ghc &#8211;help</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/haskellrascal.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/haskellrascal.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/haskellrascal.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/haskellrascal.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/haskellrascal.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/haskellrascal.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/haskellrascal.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/haskellrascal.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/haskellrascal.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/haskellrascal.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/haskellrascal.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/haskellrascal.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/haskellrascal.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/haskellrascal.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=24&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://haskellrascal.wordpress.com/2010/03/06/compile-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b490a83b92facdeaf7535fa6915f7215?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fwhaslam</media:title>
		</media:content>
	</item>
		<item>
		<title>My-Haskell-File.hs and Editing</title>
		<link>http://haskellrascal.wordpress.com/2010/03/06/files-hs-and-editing/</link>
		<comments>http://haskellrascal.wordpress.com/2010/03/06/files-hs-and-editing/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 21:32:36 +0000</pubDate>
		<dc:creator>fwhaslam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[editing]]></category>
		<category><![CDATA[ghci]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[IO Monad]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://haskellrascal.wordpress.com/?p=20</guid>
		<description><![CDATA[Haskell files are extended as *.hs.  Any text editor can be used, although Aquamacs has some language support.  You can load a file into ghci at launch time: ghci my-haskell-file.hs This will load as a default module named Main.  All function declarations are read from file and become accessible via ghci command (no let keywords necessary). The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=20&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Haskell files are extended as *.hs.  Any text editor can be used, although Aquamacs has some language support.  You can load a file into <strong>ghci</strong> at launch time:</p>
<ul>
<li>ghci my-haskell-file.hs</li>
</ul>
<p>This will load as a default module named <strong>Main</strong>.  All function declarations are read from file and become accessible via <strong>ghci</strong> command (no <strong>let</strong> keywords necessary).</p>
<p>The module <strong>Main</strong> seems to include a default reference to a function <strong>main</strong>.  If your file deines a function <strong>main</strong> then it must return some type of IO monad.  Below are two examples, the first succeeds, the second fails.</p>
<ul>
<li>main =  print ( fib 10 )   &#8212; loads successfully</li>
<li>main = fib 10    &#8212; fails to load</li>
</ul>
<p>Using a file, I can now create multiple line functions; like fibonacci below.  When I was just using ghci commands, the second &#8216;let fib ..&#8217; would remove the first &#8216;let fib..&#8217;</p>
<p style="padding-left:30px;">fib 0 = 0<br />
fib 1 = 1<br />
fib n = fib (n-1) + fib (n-2)</p>
<p>You can edit your file via <strong>ghci</strong> as follows:</p>
<ul>
<li>:set editor vi</li>
<li>:edit</li>
<li>:reload</li>
</ul>
<p>But instead, I recommend you use simply edit with an external tool, then :reload as you make changes.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/haskellrascal.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/haskellrascal.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/haskellrascal.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/haskellrascal.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/haskellrascal.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/haskellrascal.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/haskellrascal.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/haskellrascal.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/haskellrascal.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/haskellrascal.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/haskellrascal.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/haskellrascal.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/haskellrascal.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/haskellrascal.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=20&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://haskellrascal.wordpress.com/2010/03/06/files-hs-and-editing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b490a83b92facdeaf7535fa6915f7215?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fwhaslam</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple Simon Sequences</title>
		<link>http://haskellrascal.wordpress.com/2010/03/06/simple-simon-sequences/</link>
		<comments>http://haskellrascal.wordpress.com/2010/03/06/simple-simon-sequences/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 20:41:45 +0000</pubDate>
		<dc:creator>fwhaslam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sequences]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://haskellrascal.wordpress.com/?p=15</guid>
		<description><![CDATA[I love infinite sequences.  They are often the most correct way to think about a problem.  Obviously you can&#8217;t retrieve an entire sequence, but haskell gives you some tools to retrieve partial sequences.  The following will both return the list of numbers from 1 to 100: take 100 [1..] takeWhile(&#60;=100) [1..] The list syntax provides [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=15&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I love infinite sequences.  They are often the most correct way to think about a problem.  Obviously you can&#8217;t retrieve an entire sequence, but haskell gives you some tools to retrieve partial sequences.  The following will both return the list of numbers from 1 to 100:</p>
<ul>
<li><code>take 100 [1..]</code></li>
<li><code>takeWhile(&lt;=100) [1..]</code></li>
</ul>
<p>The <strong>list</strong> syntax provides easy ways to generate simple sequences.  Simply leave off a terminating value:</p>
<ul>
<li>[1,1..]   &#8212; nothing but ones</li>
<li>[1,3..]   &#8212; the odd numbers</li>
<li>[5,9..]   &#8212; every other odd number starting at 5</li>
</ul>
<p>I also to produce sequences using (lazy) recursive methods.  Note that my methods end with an &#8216;s&#8217;.  This seems to be a haskell convention.</p>
<ul>
<li>let ones = 1 : ones   &#8212; nothing but ones</li>
<li>let odds = 1 : map (2+) odds   &#8212; odd numbers</li>
<li>let fivems = 5 : map (4+) fivems</li>
</ul>
<p>Here is one of the worst possible ways to generate a sequence of square numbers:</p>
<ul>
<li>let ones = 1 : ones</li>
<li>let odds = 1 : map (2+) odds</li>
<li>let squares = 0 : zipWith (+) odds squares</li>
</ul>
<p>Mo&#8217; betterer square sequence:</p>
<ul>
<li>let squares = map (^2) [1..]</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/haskellrascal.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/haskellrascal.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/haskellrascal.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/haskellrascal.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/haskellrascal.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/haskellrascal.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/haskellrascal.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/haskellrascal.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/haskellrascal.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/haskellrascal.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/haskellrascal.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/haskellrascal.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/haskellrascal.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/haskellrascal.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=15&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://haskellrascal.wordpress.com/2010/03/06/simple-simon-sequences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b490a83b92facdeaf7535fa6915f7215?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fwhaslam</media:title>
		</media:content>
	</item>
		<item>
		<title>Let It Be</title>
		<link>http://haskellrascal.wordpress.com/2010/03/06/ghci-let-it-be/</link>
		<comments>http://haskellrascal.wordpress.com/2010/03/06/ghci-let-it-be/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 19:44:52 +0000</pubDate>
		<dc:creator>fwhaslam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[ghci]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://haskellrascal.wordpress.com/?p=5</guid>
		<description><![CDATA[I am able to do simple operations in ghci. Each of the following produces a logical result: 1 1+2 [1,2] 1:[2] [1..10] But I am initially unable to create functions.  This is especially annoying as I try to copy+paste examples from http://projecteuler.net/   I am trying to make a super-simple sequence to produce odd numbers: odds [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=5&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am able to do simple operations in <strong>ghci</strong>. Each of the following produces a logical result:</p>
<ul>
<li>1</li>
<li>1+2</li>
<li>[1,2]</li>
<li>1:[2]</li>
<li>[1..10]</li>
</ul>
<p>But I am initially unable to create functions.  This is especially annoying as I try to copy+paste examples from http://projecteuler.net/   I am trying to make a super-simple sequence to produce odd numbers:</p>
<ul>
<li>odds = 1 : map (2+) odds</li>
</ul>
<p>When I enter this as a command in <strong>ghci</strong>, it tells me:</p>
<blockquote>
<div id="_mcePaste">&lt;interactive&gt;:1:5: parse error on input `=&#8217;</div>
</blockquote>
<p>It turns out that the line is valid when it is part of a haskell file, but needs a preceeding &#8216;<strong>let</strong>&#8216; command in <strong>ghci</strong>.</p>
<ul>
<li>let odds = 1 : map (2+) odds</li>
<li>take 100 odds</li>
</ul>
<p>Tada!  An infinite sequence of odds produced by a self-referential generator.  I know that the following is simpler, but that is <em>not</em> the point.</p>
<ul>
<li>[1,3..]</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/haskellrascal.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/haskellrascal.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/haskellrascal.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/haskellrascal.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/haskellrascal.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/haskellrascal.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/haskellrascal.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/haskellrascal.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/haskellrascal.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/haskellrascal.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/haskellrascal.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/haskellrascal.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/haskellrascal.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/haskellrascal.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=5&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://haskellrascal.wordpress.com/2010/03/06/ghci-let-it-be/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b490a83b92facdeaf7535fa6915f7215?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fwhaslam</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting Started with Haskell</title>
		<link>http://haskellrascal.wordpress.com/2010/03/06/hello-world/</link>
		<comments>http://haskellrascal.wordpress.com/2010/03/06/hello-world/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 19:00:20 +0000</pubDate>
		<dc:creator>fwhaslam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[ghci]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[My journey with haskell starts with installing the Glorious Glasgow Haskell Compilation System.  I worked from the following post: http://www.haskell.org/haskellwiki/Mac_OS_X  Once this is on your system you have two tools (that I know of): ghc &#8211; a compiler that builds executables from *.hs files ghci &#8211; a command line interpreter My next step was to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=1&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My journey with haskell starts with installing the Glorious Glasgow Haskell Compilation System.  I worked from the following post: http://www.haskell.org/haskellwiki/Mac_OS_X  Once this is on your system you have two tools (that I know of):</p>
<ul>
<li>ghc &#8211; a compiler that builds executables from *.hs files</li>
<li>ghci &#8211; a command line interpreter</li>
</ul>
<p>My next step was to start reading the &#8220;Gentle Introduction to Haskell&#8221; from http://www.haskell.org/tutorial/index.html</p>
<p>Next I fired up the command line <strong>ghci</strong> and started interacting with haskell.  My first problem was that I could not exit the application.  After some reading up I discovered that all the meta-commands are preceeded by a colon.  So my micro-lesson du jour is this:</p>
<ul>
<li>:help &#8211; to figure things out</li>
<li>:quit &#8211; to run away screaming</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/haskellrascal.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/haskellrascal.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/haskellrascal.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/haskellrascal.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/haskellrascal.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/haskellrascal.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/haskellrascal.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/haskellrascal.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/haskellrascal.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/haskellrascal.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/haskellrascal.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/haskellrascal.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/haskellrascal.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/haskellrascal.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=haskellrascal.wordpress.com&amp;blog=12430917&amp;post=1&amp;subd=haskellrascal&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://haskellrascal.wordpress.com/2010/03/06/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b490a83b92facdeaf7535fa6915f7215?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fwhaslam</media:title>
		</media:content>
	</item>
	</channel>
</rss>
