<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Comment Feed for Channel 9 - C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13/RSS"></atom:link>
	<image>
		<url>http://ecn.channel9.msdn.com/o9/previewImages/100/504209_100x75.jpg</url>
		<title>Channel 9 - C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<link></link>
	</image>
	<description>In Chapter 7, Dr. Meijer teaches us about Higher-Order Functions. A function is called higher-order if it takes a function as an argument and returns a function as a result:twice&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:: (a&amp;nbsp;-&amp;gt; a)&amp;nbsp;-&amp;gt; a -&amp;gt; atwice f x = f (f x)The function twice above&amp;nbsp;is higher order because it takes a function&amp;nbsp;(f&amp;nbsp;x) as it first argument and returns a function (f(fx))&amp;nbsp;Dr. Meijer will elaborate on why higher-order functions are important and there are some really interesting side-effects of higher-order functions such as defining DSLs as collections of higher-order functions and using algebraic properties of higher-order functions to reason about programs. You should watch these in sequence (or skip around depending on your curent level of knowledge in this domain):Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 </description>
	<link></link>
	<language>en</language>
	<pubDate>Thu, 20 Jun 2013 02:42:50 GMT</pubDate>
	<lastBuildDate>Thu, 20 Jun 2013 02:42:50 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>We have reached the halfway point!</p>
<p>posted by lucjansz</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936447640000000</link>
		<pubDate>Thu, 12 Nov 2009 17:46:04 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936447640000000</guid>
		<dc:creator>lucjansz</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>The equational reasoning part on the append operator (&#43;&#43;) is wrong. This is what Erik wrote:<br /><br /><pre class="brush: text">xs &#43;&#43; ys = foldr (:) ys xs ≡ { 1 } (&#43;&#43;) ys xs = foldr (:) ys xs ≡ { 2 } (&#43;&#43;) ys = foldr (:) ys ≡ { 3 } (&#43;&#43; ys) = foldr (:) ys ≡ { 4 } (&#43;&#43;) = foldr (:)</pre><br /><br />This contains several errors:</p>
<ul>
<li>The first equality is wrong because the arguments are flipped: xs &#43;&#43; ys ≡ (&#43;&#43;) xs ys
</li><li>The second equality is true, although since the arguments of append are flipped, the function doesn't have the correct behaviour
</li><li>The third equality is wrong because it's flipping the arguments again. Although actually, (&#43;&#43; ys) isn't a valid way to define a function, so you can't write this down in Haskell. But if this were valid Haskell, the the behaviour of this append operator
 would be correct again. </li><li>The fourth equality is wrong again because it once again flips the arguments.
</li></ul>
<p><br />A correct way to define append would be:<br /><br /><pre class="brush: text">(&#43;&#43;) = flip (foldr (:))</pre></p>
<p>&nbsp;</p>
<p>Having said all that, I really like this series.</p>
<p>&nbsp;</p>
<p>Keep on going Erik! <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>posted by Tom Lokhorst</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936524210000000</link>
		<pubDate>Thu, 12 Nov 2009 19:53:41 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936524210000000</guid>
		<dc:creator>Tom Lokhorst</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>A function that returns a function? That is clear: It's a&nbsp;curried function!</p>
<p>&nbsp;</p>
<p><pre class="brush: csharp">a -&gt; b // function a -&gt; b -&gt; c // curried function (a -&gt; b) -&gt; c // but a -&gt; (b -&gt; c) // vs</pre></p>
<p>&nbsp;</p>
<p>Apparently, if history be the judge, currying ought to be called Schönfinkeling&nbsp;and curried functions Schönfinkeled functions after the true inventor of this transformation,&nbsp;<a href="http://en.wikipedia.org/wiki/Moses_Sch%C3%B6nfinkel">Moses Schönfinkel</a>.
 Sad fate: his papers were burned for heating&nbsp;by his neighbors and he ended up in a sanatorium! Maybe currying is safer after all.</p>
<p>posted by exoteric</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936530250000000</link>
		<pubDate>Thu, 12 Nov 2009 20:03:45 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936530250000000</guid>
		<dc:creator>exoteric</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>I don't think it's wrong at all. He hasn't flipped the arguments, he puts &quot;ys&quot; as the base case for the fold, meaning it will end up &quot;to the right&quot; (hence the &quot;r&quot; in foldr).</p>
<p>&nbsp;</p>
<p>EDIT: Ah, I see what you mean, I thought you meant the first &quot;=&quot; sign. sorry about that, anyway. I'll keep this here because it's neat.</p>
<p>&nbsp;</p>
<p>Put this in a Haskell file:</p>
<p><pre class="brush: text">
import Test.QuickCheck 
prop_Concat :: [Int] -&gt; [Int] -&gt; Bool 
prop_Concat xs ys = xs &#43;&#43; ys == foldr (:) ys xs
 
</pre></p>
<p>&nbsp;</p>
<p>This code defines a quickCheck property, which is a way of automatically generating tests in Haskell. You specify what you expect to be true for the inputs, and it generates tons of data for you and verifies that the property is indeed true.</p>
<p>&nbsp;</p>
<p>Then open it in GHCi (or hugs, I think) and do:</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><pre class="brush: text">
*Main&gt; quickCheck prop_Concat 
OK, passed 100 tests</pre></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>posted by sylvan</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936542690000000</link>
		<pubDate>Thu, 12 Nov 2009 20:24:29 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936542690000000</guid>
		<dc:creator>sylvan</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>Right <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>&nbsp;</p>
<p>To be clear to everyone: What I'm saying is that the <strong>equalities</strong> are wrong. The first definition is perfectly fine.</p>
<p>&nbsp;</p>
<p>Also sylvan: Very nince demo of QuickCheck, and a good thing you put a type signature on
<code>prop_Concat</code>.</p>
<p>When I started using QuickCheck I didn't do that and GHCi defaulted that kind of a function to:
<code>prop_Concat :: [()] -&gt; [()] -&gt; Bool</code></p>
<p>So the tests all ran OK and I ended up submitting a wrong solution to an exercise to my teacher...</p>
<p>posted by Tom Lokhorst</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936546420000000</link>
		<pubDate>Thu, 12 Nov 2009 20:30:42 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936546420000000</guid>
		<dc:creator>Tom Lokhorst</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>Again nice lecture!</p>
<p>&nbsp;</p>
<p>A comment about implementing takeWhile and dropWhile using foldr. These are functions to take or drop elements at the beginning of a list. So, I think it would be easier to implement them using foldl (fold left). Can it be done with foldr? I’m not sure.
 The drawback to implement them with fold is that they would be useless when dealing with infinite lists. That is because fold(r|l) consume the whole list before producing a result.</p>
<p>&nbsp;</p>
<p>Here is my take on both using foldl</p>
<p><pre class="brush: text">takeWhile' :: (a -&gt; Bool) -&gt; [a] -&gt; [a] takeWhile' p = snd . foldl (\(e,v) x -&gt; if e then (e,v) else if p x then (False,v&#43;&#43;[x]) else (True,v)) (False,[]) dropWhile' :: (a -&gt; Bool) -&gt; [a] -&gt; [a] dropWhile' p = snd . foldl (\(e,v) x -&gt; if
 e then (e,v&#43;&#43;[x]) else if p x then (True,v) else (False,v&#43;&#43;[])) (False,[]) </pre></p>
<p>&nbsp;</p>
<p>posted by paks8150</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936632510000000</link>
		<pubDate>Thu, 12 Nov 2009 22:54:11 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936632510000000</guid>
		<dc:creator>paks8150</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>I'd say its easier to implement takeWhile using foldr:<br /><br /><pre class="brush: text">takeWhile p = foldr (\x xs -&gt; if p x then x : xs else []) []</pre><br /><br />Also, foldr most definitely does not consume the whole list before producing a result. Take this definition:<br /><br /><pre class="brush: text">foldr :: (a -&gt; b -&gt; b) -&gt; b -&gt; [a] -&gt; b foldr f z [] = z foldr f z (x:xs) = f x (foldr f z xs)</pre><br /><br />As you can see in the cons case; foldr calls <code>f</code> with <code>x</code> and the result of a recursive call.<br />However, since Haskell is lazy, <code>f</code> gets executed <em>before</em> the result of the recursive call is computed. If
<code>f</code> decides to never inspects its second argument, the recursive call will never be evaluated. So that's why you can do:
<code>takeWhile (&lt;4) [0..]</code></p>
<p>&nbsp;</p>
<p>However, you are right about foldl. <br /><br /><pre class="brush: text">foldl :: (a -&gt; b -&gt; a) -&gt; a -&gt; [b] -&gt; a foldl f z [] = z foldl f z (x:xs) = foldl (f z x) xs</pre><br /><br /><code>foldl</code> first recurses, before executing the <code>f</code> function that produces the result value.</p>
<p>So calling the <code>takeWhile'</code>, defined below, with an infinite list will result in an infinite computation.</p>
<p>&nbsp;</p>
<p><pre class="brush: text">takeWhile' p = foldl (\ys x -&gt; if p x then ys &#43;&#43; [x] else ys) []</pre></p>
<p>posted by Tom Lokhorst</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936653560000000</link>
		<pubDate>Thu, 12 Nov 2009 23:29:16 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936653560000000</guid>
		<dc:creator>Tom Lokhorst</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>Nice post Tom. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>&nbsp;</p>
<p>So much to learn.</p>
<p>posted by paks8150</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936800510000000</link>
		<pubDate>Fri, 13 Nov 2009 03:34:11 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633936800510000000</guid>
		<dc:creator>paks8150</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>I much prefer this for reverse:</p>
<p>&nbsp;</p>
<p><pre class="brush: text">reverse = foldl (flip (:)) []</pre></p>
<p>&nbsp;</p>
<p>The 'foldl' expresses the eagerness required by reverse, and the 'flip (<img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' />' expresses the all-pairs transposition.</p>
<p>posted by piersh</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633937023210000000</link>
		<pubDate>Fri, 13 Nov 2009 09:45:21 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633937023210000000</guid>
		<dc:creator>piersh</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>These are great lectures. &nbsp;Unfortunately, Silverlight running on Safari 4.0 / Snow Leopard is terrible.</p>
<p>&nbsp;</p>
<p>Microsoft would be well served to upgrade to Apple's QuickTime, but I'm confident that would never happen.</p>
<p>posted by HaskellGuy</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633937298540000000</link>
		<pubDate>Fri, 13 Nov 2009 17:24:14 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633937298540000000</guid>
		<dc:creator>HaskellGuy</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>Just click on the Media Downloads link and choose MP4.....</p>
<p>C</p>
<p>posted by Charles</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633937300990000000</link>
		<pubDate>Fri, 13 Nov 2009 17:28:19 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633937300990000000</guid>
		<dc:creator>Charles</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>What I don't get is the definition of reverse:</p>
<p>Shouldn't it be</p>
<p>reverse' = foldr (\x xs -&gt; xs&#43;&#43;[x]) []</p>
<p>posted by pangron</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633937900320000000</link>
		<pubDate>Sat, 14 Nov 2009 10:07:12 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633937900320000000</guid>
		<dc:creator>pangron</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>homework:</p>
<p>&nbsp;</p>
<p>2) Express the comprehension [f x | x &lt;- xs, p x] using the functions map and filter.</p>
<p><pre class="brush: text">mapfilter :: (a -&gt; b) -&gt; (a -&gt; Bool) -&gt; [a] -&gt; [b] mapfilter f p = map f . filter p</pre></p>
<p>&nbsp;</p>
<p>3) Redefine map f and filter p using foldr.</p>
<p><pre class="brush: text">map' :: (a -&gt; b) -&gt; [a] -&gt; [b] map' f = foldr (\x v -&gt; f x:v) [] filter' :: (a -&gt; Bool) -&gt; [a] -&gt; [a] filter' p = foldr (\x v -&gt; if p x then x:v else v) []</pre></p>
<p>&nbsp;</p>
<p>posted by paks8150</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633951905570000000</link>
		<pubDate>Mon, 30 Nov 2009 15:09:17 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633951905570000000</guid>
		<dc:creator>paks8150</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>I *think* Erik said that using the sum . map variant on length would be less efficient but it runs faster for me.&nbsp; (using timing method from
<a href="http://www.haskell.org/haskellwiki/Timing_computations">here</a>).</p>
<p>&nbsp;</p>
<p><pre class="brush: text">import Text.Printf import Control.Exception import System.CPUTime time :: IO t -&gt; IO t time a = do start &lt;- getCPUTime v &lt;- a end &lt;- getCPUTime let diff = (fromIntegral (end - start)) / (10^12) printf &quot;Computation time: %0.3f sec\n&quot; (diff
 :: Double) return v len1 = sum . map ( \ _ -&gt; 1 ) len2 = foldr ( \ _ n -&gt; n&#43;1) 0 limit = 500000 main = do putStrLn &quot;Len1:&quot; time $ len1 [1..limit] `seq` return () putStrLn &quot;Len2:&quot; time $ len2 [1..limit] `seq` return ()</pre></p>
<p>&nbsp;</p>
<p>I get</p>
<p><pre class="brush: text">*Main&gt; :run main Len1: Computation time: 0.719 sec Len2: Computation time: 1.141 sec</pre></p>
<p>posted by BJG</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633977820690000000</link>
		<pubDate>Wed, 30 Dec 2009 15:01:09 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c633977820690000000</guid>
		<dc:creator>BJG</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>Hey,</p>
<p>&nbsp;</p>
<p>map :: (a -&gt; b) -&gt; [a] -&gt; [b]<br />map f [] = []<br />map f (x:xs) = f x : Main.map f xs<br /><br />map' :: (a -&gt; b) -&gt; [a] -&gt; [b]<br />map' f [] = []<br />map' f xs = Main.foldr (\x xs -&gt; f x : xs) [] xs<br /><br />filter :: (a -&gt; Bool) -&gt; [a] -&gt; [a]<br />filter f [] = []<br />filter f (x:xs) | f x = x : Main.filter f xs <br />| otherwise = Main.filter f xs<br /><br />filter' :: (a -&gt; Bool) -&gt; [a] -&gt; [a]<br />filter' f [] = []<br />filter' f xs = Main.foldr (\x xs -&gt; if f x then x : xs else xs) [] xs<br /><br />-- Need Integral class, since method div is provided there <br />even :: Integral a =&gt; a -&gt; Bool<br />even a = if ((a `div` 2)*2) == a then True else False<br /><br />foldr :: (a -&gt; b -&gt; b) -&gt; b -&gt; [a] -&gt; b<br />foldr f v [] = v<br />foldr f v (x:xs) = f x (Main.foldr f v xs)<br /><br /></p>
<p>Sohail Qayum Malik</p>
<p>posted by Aeon</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c634113469920000000</link>
		<pubDate>Sat, 05 Jun 2010 15:03:12 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c634113469920000000</guid>
		<dc:creator>Aeon</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13</title>
		<description>
			<![CDATA[
<p>length'&nbsp; = sum . map(\_ -&gt; 1)<br />length'' = (foldr (\x xs -&gt; x &#43; xs) 0) . (foldr (\_ xs -&gt; [1] &#43;&#43; xs) [])</p>
<p>&nbsp;</p>
<p>all' :: (a -&gt; Bool) -&gt; [a] -&gt; Bool<br />--all' p as = foldr (\x xs -&gt; x &amp;&amp; xs) True $ foldr (\x xs -&gt; if p x then True : xs else False : xs) [True] as<br />all' p xs = foldr (\x xs -&gt; p x &amp;&amp; xs) True xs<br /><br />any' :: (a -&gt; Bool) -&gt; [a] -&gt; Bool<br />any' p xs = foldr (\x xs -&gt; p x || xs) False xs<br /><br />takewhile' :: (a -&gt; Bool) -&gt; [a] -&gt; [a]<br />takewhile' p xs = foldr (\x xs -&gt; if p x then x : xs else xs) [] xs<br /><br />dropwhile' :: (a -&gt; Bool) -&gt; [a] -&gt; [a]<br />dropwhile' p xs = foldr (\x xs -&gt; if not (p x) then x : xs else xs) [] xs</p>
<p>Sohail Qayum Malik</p>
<p>posted by Aeon</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c634114552360000000</link>
		<pubDate>Sun, 06 Jun 2010 21:07:16 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-7-of-13#c634114552360000000</guid>
		<dc:creator>Aeon</dc:creator>
	</item>
</channel>
</rss>