<?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: Real world functional programming in Scala &#8211; comparing Java, Clojure and Scala</title>
	<atom:link href="http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/</link>
	<description></description>
	<lastBuildDate>Thu, 11 Mar 2010 16:23:01 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Alexey Tarasevich</title>
		<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/comment-page-1/#comment-92110</link>
		<dc:creator>Alexey Tarasevich</dc:creator>
		<pubDate>Fri, 17 Jul 2009 12:18:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2412#comment-92110</guid>
		<description>I think, while you are not using domain-specific macros your Clojure will not look remarkably better then Scala :)</description>
		<content:encoded><![CDATA[<p>I think, while you are not using domain-specific macros your Clojure will not look remarkably better then Scala <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anders</title>
		<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/comment-page-1/#comment-92093</link>
		<dc:creator>Anders</dc:creator>
		<pubDate>Thu, 16 Jul 2009 12:10:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2412#comment-92093</guid>
		<description>I have read tutorial how to write code more functional, i like both Scala and Clojure, but to get developer hocked-on functional development it could be easy way to show how to do it, with the language they all ready use.
IBM have a good introduction.

Functional programming in the Java language
http://www.ibm.com/developerworks/java/library/j-fp.html

mvh Anders</description>
		<content:encoded><![CDATA[<p>I have read tutorial how to write code more functional, i like both Scala and Clojure, but to get developer hocked-on functional development it could be easy way to show how to do it, with the language they all ready use.<br />
IBM have a good introduction.</p>
<p>Functional programming in the Java language<br />
<a href="http://www.ibm.com/developerworks/java/library/j-fp.html" rel="nofollow">http://www.ibm.com/developerworks/java/library/j-fp.html</a></p>
<p>mvh Anders</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Azarov</title>
		<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/comment-page-1/#comment-92081</link>
		<dc:creator>Alexander Azarov</dc:creator>
		<pubDate>Tue, 14 Jul 2009 11:24:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2412#comment-92081</guid>
		<description>I guess you have a mistake in the update. When you don&#039;t write &quot;else&quot;, &quot;if&quot; returns Unit.</description>
		<content:encoded><![CDATA[<p>I guess you have a mistake in the update. When you don&#8217;t write &#8220;else&#8221;, &#8220;if&#8221; returns Unit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arjan Blokzijl</title>
		<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/comment-page-1/#comment-92064</link>
		<dc:creator>Arjan Blokzijl</dc:creator>
		<pubDate>Sun, 12 Jul 2009 06:00:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2412#comment-92064</guid>
		<description>Hi Stuart,

My first version also doesn&#039;t handle infinite collections that well, I&#039;ve posted an update to the blog with a version that does some rather crude handling of this using Scala&#039;s Stream class, which implements a lazy list. This version is less generic than the first one, however.</description>
		<content:encoded><![CDATA[<p>Hi Stuart,</p>
<p>My first version also doesn&#8217;t handle infinite collections that well, I&#8217;ve posted an update to the blog with a version that does some rather crude handling of this using Scala&#8217;s Stream class, which implements a lazy list. This version is less generic than the first one, however.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arjan Blokzijl</title>
		<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/comment-page-1/#comment-92058</link>
		<dc:creator>Arjan Blokzijl</dc:creator>
		<pubDate>Sat, 11 Jul 2009 06:48:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2412#comment-92058</guid>
		<description>@ASD: You&#039;re correct, that makes the Scala version more concise, and demonstrates my mediocre knowledge of the Scala collections API. As a side note, in the redesigned collections library in the trunk, firstOption is deprecated and its now headOption. About the null checks: in the Clojure version you can pass nil to the function, and the function still works. One of the reasons the apache commons libraries are widely used is that they handle the annoying null checking. I&#039;ve tried to re-create the three Clojure functions in Scala, and in order to have all cases work correctly, the null checking is still required I believe.</description>
		<content:encoded><![CDATA[<p>@ASD: You&#8217;re correct, that makes the Scala version more concise, and demonstrates my mediocre knowledge of the Scala collections API. As a side note, in the redesigned collections library in the trunk, firstOption is deprecated and its now headOption. About the null checks: in the Clojure version you can pass nil to the function, and the function still works. One of the reasons the apache commons libraries are widely used is that they handle the annoying null checking. I&#8217;ve tried to re-create the three Clojure functions in Scala, and in order to have all cases work correctly, the null checking is still required I believe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Halloway</title>
		<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/comment-page-1/#comment-92056</link>
		<dc:creator>Stuart Halloway</dc:creator>
		<pubDate>Sat, 11 Jul 2009 03:56:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2412#comment-92056</guid>
		<description>Cay, Eastsun, 

The direct translations are concise, but they lack the generality of the Clojure version. How would you code a Scala version to handle an infinite collection?</description>
		<content:encoded><![CDATA[<p>Cay, Eastsun, </p>
<p>The direct translations are concise, but they lack the generality of the Clojure version. How would you code a Scala version to handle an infinite collection?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eastsun</title>
		<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/comment-page-1/#comment-92041</link>
		<dc:creator>Eastsun</dc:creator>
		<pubDate>Thu, 09 Jul 2009 01:11:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2412#comment-92041</guid>
		<description>my scala solution(just a direct translation from the java version)
scala&gt; def indexOfAny(str :String, seq :Array[Char]):Option[Int] = {
     &#124;     if(str == null &#124;&#124; seq == null) None
     &#124;     else (0 until str.length) find {i =&gt; seq.contains(str(i)) }
     &#124; }
indexOfAny: (String,Array[Char])Option[Int]</description>
		<content:encoded><![CDATA[<p>my scala solution(just a direct translation from the java version)<br />
scala&gt; def indexOfAny(str :String, seq :Array[Char]):Option[Int] = {<br />
     |     if(str == null || seq == null) None<br />
     |     else (0 until str.length) find {i =&gt; seq.contains(str(i)) }<br />
     | }<br />
indexOfAny: (String,Array[Char])Option[Int]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cay Horstmann</title>
		<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/comment-page-1/#comment-92040</link>
		<dc:creator>Cay Horstmann</dc:creator>
		<pubDate>Thu, 09 Jul 2009 01:09:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2412#comment-92040</guid>
		<description>This is an interesting exercise, but it might scare away Java refugees who think that everything in Scala must be rethought with a mess of predicates and zipped lists. This particular algorithm translates easily into something that a Java refugee can grasp pretty quickly:

def indexOfAny(str : String, searchChars : Array[Char]) = 
  if (str == null &#124;&#124; searchChars == null) List() else
  for { i &lt;- 0 until str.length if (searchChars.contains(str(i))) } yield i

It collects all matching indices, not just the first one.</description>
		<content:encoded><![CDATA[<p>This is an interesting exercise, but it might scare away Java refugees who think that everything in Scala must be rethought with a mess of predicates and zipped lists. This particular algorithm translates easily into something that a Java refugee can grasp pretty quickly:</p>
<p>def indexOfAny(str : String, searchChars : Array[Char]) =<br />
  if (str == null || searchChars == null) List() else<br />
  for { i &lt;- 0 until str.length if (searchChars.contains(str(i))) } yield i</p>
<p>It collects all matching indices, not just the first one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asd</title>
		<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/comment-page-1/#comment-92034</link>
		<dc:creator>Asd</dc:creator>
		<pubDate>Wed, 08 Jul 2009 12:07:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2412#comment-92034</guid>
		<description>D&#039;oh, my Scala could be even shorter:

def indexOfAny(pred:Seq[Any], coll:Seq[Any]) = indexedFilter(pred,coll).firstOption</description>
		<content:encoded><![CDATA[<p>D&#8217;oh, my Scala could be even shorter:</p>
<p>def indexOfAny(pred:Seq[Any], coll:Seq[Any]) = indexedFilter(pred,coll).firstOption</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asd</title>
		<link>http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/comment-page-1/#comment-92032</link>
		<dc:creator>Asd</dc:creator>
		<pubDate>Wed, 08 Jul 2009 11:27:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2412#comment-92032</guid>
		<description>The Scala could definitely be shorter. I am omitting the null checks (you didn&#039;t put any type checks in the clojure did you?):

def indexedFilter(pred:Seq[Any], coll:Seq[Any]) =
  coll.toList.zipWithIndex.filter(p =&gt; pred.contains(p._1)).map(p =&gt; p._2)

 def indexOfAny(pred:Seq[Any], coll:Seq[Any]) = indexedFilter(pred,coll) match {
   case x::xs =&gt; Some(x)
   case _ =&gt; None
 }</description>
		<content:encoded><![CDATA[<p>The Scala could definitely be shorter. I am omitting the null checks (you didn&#8217;t put any type checks in the clojure did you?):</p>
<p>def indexedFilter(pred:Seq[Any], coll:Seq[Any]) =<br />
  coll.toList.zipWithIndex.filter(p =&gt; pred.contains(p._1)).map(p =&gt; p._2)</p>
<p> def indexOfAny(pred:Seq[Any], coll:Seq[Any]) = indexedFilter(pred,coll) match {<br />
   case x::xs =&gt; Some(x)<br />
   case _ =&gt; None<br />
 }</p>
]]></content:encoded>
	</item>
</channel>
</rss>
