<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Ruby and Functional Programming</title>
	<atom:link href="http://www.khelll.com/blog/ruby/ruby-and-functional-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.khelll.com/blog/ruby/ruby-and-functional-programming/</link>
	<description>What web development means....</description>
	<lastBuildDate>Tue, 13 Jul 2010 05:39:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: A functional approach to Ruby &#171; The Knut Hellan Blog</title>
		<link>http://www.khelll.com/blog/ruby/ruby-and-functional-programming/comment-page-1/#comment-9434</link>
		<dc:creator>A functional approach to Ruby &#171; The Knut Hellan Blog</dc:creator>
		<pubDate>Tue, 22 Jun 2010 09:51:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.khelll.com/blog/?p=351#comment-9434</guid>
		<description>[...] I consider the discussion around Ruby being a functional language or not academic with no effect on my use of the language. There is no doubt that functional programming is possible in Ruby, but bear in mind that it does not enforce pure functions that do not have side-effects. As for good overviews of functional programming in Ruby, I suggest Khaled alHabache’s post Ruby and Functional Programming. [...]</description>
		<content:encoded><![CDATA[<p>[...] I consider the discussion around Ruby being a functional language or not academic with no effect on my use of the language. There is no doubt that functional programming is possible in Ruby, but bear in mind that it does not enforce pure functions that do not have side-effects. As for good overviews of functional programming in Ruby, I suggest Khaled alHabache’s post Ruby and Functional Programming. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruby enumerators (and a script to list all Google search results) &#124; I am stealing ideas</title>
		<link>http://www.khelll.com/blog/ruby/ruby-and-functional-programming/comment-page-1/#comment-9070</link>
		<dc:creator>Ruby enumerators (and a script to list all Google search results) &#124; I am stealing ideas</dc:creator>
		<pubDate>Sun, 23 May 2010 17:06:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.khelll.com/blog/?p=351#comment-9070</guid>
		<description>[...] and reduce is a used a lot in functional programming. (Map is also known as collect; reduce, as inject or fold). Do you think this code is [...]</description>
		<content:encoded><![CDATA[<p>[...] and reduce is a used a lot in functional programming. (Map is also known as collect; reduce, as inject or fold). Do you think this code is [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: O Mercado Cangaceiro &#171; public abstract void</title>
		<link>http://www.khelll.com/blog/ruby/ruby-and-functional-programming/comment-page-1/#comment-8099</link>
		<dc:creator>O Mercado Cangaceiro &#171; public abstract void</dc:creator>
		<pubDate>Sun, 04 Apr 2010 18:01:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.khelll.com/blog/?p=351#comment-8099</guid>
		<description>[...] uma linguagem como o Ruby. Sua alta ortogonalidade permite a escrita de DSLs sem esforço algum. O paradigma funcional é mais fácil de ser compreendido: mudança de estados, para quem conhece o mínimo de matemática, é algo mais natural que a [...]</description>
		<content:encoded><![CDATA[<p>[...] uma linguagem como o Ruby. Sua alta ortogonalidade permite a escrita de DSLs sem esforço algum. O paradigma funcional é mais fácil de ser compreendido: mudança de estados, para quem conhece o mínimo de matemática, é algo mais natural que a [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Kane Parker</title>
		<link>http://www.khelll.com/blog/ruby/ruby-and-functional-programming/comment-page-1/#comment-2140</link>
		<dc:creator>Matthew Kane Parker</dc:creator>
		<pubDate>Mon, 25 May 2009 14:17:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.khelll.com/blog/?p=351#comment-2140</guid>
		<description>&quot;However following recursion style has itâ€™s own tax: Performance&quot;

that&#039;s a common misconception, and often indicates an ignorance of asymptotic notation / algorithm analysis. recursive solutions, just like iterative solutions, are neither inherently efficient nor inherently inefficient. The real danger with recursion is duplication of work. 

Consider this naive implementation of generating an array of the first n fibonacci numbers:

&lt;code&gt;
def nfib(n)
  seq = []
  (1..n).each do &#124;nth&#124;
    seq &lt;&lt; nfibr(nth)
  end
  seq
end

def nfibr(nth)
  if nth &lt;= 2
    1
  else
    nfibr(nth-1) + nfibr(nth-2)
  end
end
&lt;/code&gt;

notice that nfibr(4) would first call nfibr(3) + nfibr(2), and nfibr(3) would call nfibr(2) + nfibr(1) - the problem being that nfibr(2) was already calculated from the nfibr(3) call. it&#039;s not hard to see that this method runs on the order of O(n^n). 

however, a linear recursive solution (that builds fibonacci numbers from the bottom up) is trivial to conceive: 

&lt;code&gt;
def fib(times)
  fibr([1,1], 1, 1, times-2)
end

def fibr(seq, n_min_2, n_min_1, times)
  if times &gt; 0
    n = n_min_2 + n_min_1
    seq &lt;&lt; n
    fibr(seq, n_min_1, n, times-1)
  else
    seq
  end
end
&lt;/code&gt;

Whereas nfib(40) will take something on the order of several millennium to compute, fib(40) returns instantly, since it&#039;s running in O(n) time.</description>
		<content:encoded><![CDATA[<p>&#8220;However following recursion style has itâ€™s own tax: Performance&#8221;</p>
<p>that&#8217;s a common misconception, and often indicates an ignorance of asymptotic notation / algorithm analysis. recursive solutions, just like iterative solutions, are neither inherently efficient nor inherently inefficient. The real danger with recursion is duplication of work. </p>
<p>Consider this naive implementation of generating an array of the first n fibonacci numbers:</p>
<p><code><br />
def nfib(n)<br />
  seq = []<br />
  (1..n).each do |nth|<br />
    seq &lt;&lt; nfibr(nth)<br />
  end<br />
  seq<br />
end</p>
<p>def nfibr(nth)<br />
  if nth &lt;= 2<br />
    1<br />
  else<br />
    nfibr(nth-1) + nfibr(nth-2)<br />
  end<br />
end<br />
</code></p>
<p>notice that nfibr(4) would first call nfibr(3) + nfibr(2), and nfibr(3) would call nfibr(2) + nfibr(1) &#8211; the problem being that nfibr(2) was already calculated from the nfibr(3) call. it&#8217;s not hard to see that this method runs on the order of O(n^n). </p>
<p>however, a linear recursive solution (that builds fibonacci numbers from the bottom up) is trivial to conceive: </p>
<p><code><br />
def fib(times)<br />
  fibr([1,1], 1, 1, times-2)<br />
end</p>
<p>def fibr(seq, n_min_2, n_min_1, times)<br />
  if times &gt; 0<br />
    n = n_min_2 + n_min_1<br />
    seq &lt;&lt; n<br />
    fibr(seq, n_min_1, n, times-1)<br />
  else<br />
    seq<br />
  end<br />
end<br />
</code></p>
<p>Whereas nfib(40) will take something on the order of several millennium to compute, fib(40) returns instantly, since it&#8217;s running in O(n) time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Posts about Programming from google blogs as of May 24, 2009 &#171; tryfly.com</title>
		<link>http://www.khelll.com/blog/ruby/ruby-and-functional-programming/comment-page-1/#comment-2132</link>
		<dc:creator>Posts about Programming from google blogs as of May 24, 2009 &#171; tryfly.com</dc:creator>
		<pubDate>Sun, 24 May 2009 23:51:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.khelll.com/blog/?p=351#comment-2132</guid>
		<description>[...] (in order to get HD channels). However, my VCR&#8217;s timer programming no longer works (curre.   Ruby and Functional Programming - Khaled alHabache&#039;s official blog - khelll.com 05/24/2009 In computer science, functional programming is a programming paradigm that [...]</description>
		<content:encoded><![CDATA[<p>[...] (in order to get HD channels). However, my VCR&#8217;s timer programming no longer works (curre.   Ruby and Functional Programming &#8211; Khaled alHabache&#39;s official blog &#8211; khelll.com 05/24/2009 In computer science, functional programming is a programming paradigm that [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shadowfiend</title>
		<link>http://www.khelll.com/blog/ruby/ruby-and-functional-programming/comment-page-1/#comment-2128</link>
		<dc:creator>Shadowfiend</dc:creator>
		<pubDate>Sun, 24 May 2009 18:29:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.khelll.com/blog/?p=351#comment-2128</guid>
		<description>Worth mentioning is that you can technically achieve lazy evaluation, you just have to jump through some hoops. You can do this by passing in lambdas instead of actual values and calling them on the other end.

This is, of course, super ugly :-P</description>
		<content:encoded><![CDATA[<p>Worth mentioning is that you can technically achieve lazy evaluation, you just have to jump through some hoops. You can do this by passing in lambdas instead of actual values and calling them on the other end.</p>
<p>This is, of course, super ugly <img src='http://www.khelll.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruby and Functional Programming - Khaled alHabache&#39;s official blog</title>
		<link>http://www.khelll.com/blog/ruby/ruby-and-functional-programming/comment-page-1/#comment-2126</link>
		<dc:creator>Ruby and Functional Programming - Khaled alHabache&#39;s official blog</dc:creator>
		<pubDate>Sun, 24 May 2009 18:14:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.khelll.com/blog/?p=351#comment-2126</guid>
		<description>[...] See more here:Â  Ruby and Functional Programming - Khaled alHabache&#039;s official blog [...]</description>
		<content:encoded><![CDATA[<p>[...] See more here:Â  Ruby and Functional Programming &#8211; Khaled alHabache&#39;s official blog [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damian Nicholson</title>
		<link>http://www.khelll.com/blog/ruby/ruby-and-functional-programming/comment-page-1/#comment-2124</link>
		<dc:creator>Damian Nicholson</dc:creator>
		<pubDate>Sun, 24 May 2009 13:20:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.khelll.com/blog/?p=351#comment-2124</guid>
		<description>Thanks for the writeup! Especially the part to do with currying...it&#039;s something I&#039;ll be reading into a bit more, I guess it&#039;s time to upgrade to 1.9 now to try it out.</description>
		<content:encoded><![CDATA[<p>Thanks for the writeup! Especially the part to do with currying&#8230;it&#8217;s something I&#8217;ll be reading into a bit more, I guess it&#8217;s time to upgrade to 1.9 now to try it out.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
