<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>Comments for Japila :: verba docent, exempla trahunt</title>
	
	<link>http://blog.japila.pl</link>
	<description>Functional languages (Clojure), Java EE, and IBM WebSphere</description>
	<lastBuildDate>Wed, 22 Feb 2012 04:33:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/blog-japila-pl-comments" /><feedburner:info uri="blog-japila-pl-comments" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Comment on Today’s a palindrome – how to check palindromes in Clojure by Norman Richards</title>
		<link>http://feedproxy.google.com/~r/blog-japila-pl-comments/~3/hEi3Anp66cs/</link>
		<dc:creator>Norman Richards</dc:creator>
		<pubDate>Wed, 22 Feb 2012 04:33:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.japila.pl/?p=747#comment-1011</guid>
		<description>In addition to what the prior poster says, I'd note a few more things.

- [let lst (list)] strikes be as being particularly non-idiomatic.  I'd use () instead.

- (mapcat #(conj lst %1) s) is particularly redundant.  If you want to force a seq, use (seq s).  If you really need to force the issue for educational reasons, perhaps (map identity s) ?

- Of course s is a seq, so you could simplify your reduce to (reduce #(str %2 %1) s)

- Another reduce option: (reduce str (into () s)  But, of course there's no map here.</description>
		<content:encoded><![CDATA[<p>In addition to what the prior poster says, I&#8217;d note a few more things.</p>
<p>- [let lst (list)] strikes be as being particularly non-idiomatic.  I&#8217;d use () instead.</p>
<p>- (mapcat #(conj lst %1) s) is particularly redundant.  If you want to force a seq, use (seq s).  If you really need to force the issue for educational reasons, perhaps (map identity s) ?</p>
<p>- Of course s is a seq, so you could simplify your reduce to (reduce #(str %2 %1) s)</p>
<p>- Another reduce option: (reduce str (into () s)  But, of course there&#8217;s no map here.</p>
<img src="http://feeds.feedburner.com/~r/blog-japila-pl-comments/~4/hEi3Anp66cs" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blog.japila.pl/2012/02/todays-a-palindrome-how-to-check-palindromes-in-clojure/#comment-1011</feedburner:origLink></item>
	<item>
		<title>Comment on Today’s a palindrome – how to check palindromes in Clojure by Craig Andera</title>
		<link>http://feedproxy.google.com/~r/blog-japila-pl-comments/~3/kr6gdUKftwU/</link>
		<dc:creator>Craig Andera</dc:creator>
		<pubDate>Wed, 22 Feb 2012 03:34:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.japila.pl/?p=747#comment-1010</guid>
		<description>Strings are associative by index. So you could do something like (map (partial nth s) (range (dec (count s)) -1 -1)) to reverse the string.</description>
		<content:encoded><![CDATA[<p>Strings are associative by index. So you could do something like (map (partial nth s) (range (dec (count s)) -1 -1)) to reverse the string.</p>
<img src="http://feeds.feedburner.com/~r/blog-japila-pl-comments/~4/kr6gdUKftwU" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blog.japila.pl/2012/02/todays-a-palindrome-how-to-check-palindromes-in-clojure/#comment-1010</feedburner:origLink></item>
	<item>
		<title>Comment on Today’s a palindrome – how to check palindromes in Clojure by Andrew</title>
		<link>http://feedproxy.google.com/~r/blog-japila-pl-comments/~3/GKTGtHW6_-o/</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 22 Feb 2012 02:39:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.japila.pl/?p=747#comment-1009</guid>
		<description>Hi Jacek,

Minor nitpick: square brackets denote a vector literal in Clojure and are different to arrays (which are java mutable arrays).

You're string reverse function is a lot more complicated than it needs to be. Here &lt;code&gt;(let [lst (list)] … #(conj lst %1) …)&lt;/code&gt; is a long way of saying &lt;code&gt;list&lt;/code&gt;;  Note that &lt;code&gt;()&lt;/code&gt; is also a literal for the empty list in Clojure.  However, mapping list over a sequence and then concatenating the result is an identity operation on the sequence. You could just call &lt;code&gt;seq&lt;/code&gt; on &lt;code&gt;s&lt;/code&gt;. Lastly, because you are passing s to a seq consuming function anyway, you can elide the call to &lt;code&gt;seq&lt;/code&gt; yourself.

This simplifies &lt;code&gt;my-reverse&lt;/code&gt; down to:

&lt;code&gt;(defn str-reverse [s] (reduce #(str %2 %) "" s)&lt;/code&gt;

An alternate formulation that takes advantage of lists building from the front might be

&lt;code&gt;(defn str-reverse [s] (apply str (reduce conj () s)))&lt;/code&gt;


&lt;blockquote&gt;
I think that in order to fully embrace the concept of functional programming is to use the three functions: map, reduce and filter extensively, and so I insisted on using them to tackle the problem.
&lt;/blockquote&gt;

Another fun variation of this is to use &lt;code&gt;juxt&lt;/code&gt;, &lt;code&gt;partial&lt;/code&gt; and &lt;code&gt;comp&lt;/code&gt;:

&lt;code&gt;(def palindrome? (comp (partial apply =) (juxt seq (partial reduce conj ()))))&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Hi Jacek,</p>
<p>Minor nitpick: square brackets denote a vector literal in Clojure and are different to arrays (which are java mutable arrays).</p>
<p>You&#8217;re string reverse function is a lot more complicated than it needs to be. Here <code>(let [lst (list)] … #(conj lst %1) …)</code> is a long way of saying <code>list</code>;  Note that <code>()</code> is also a literal for the empty list in Clojure.  However, mapping list over a sequence and then concatenating the result is an identity operation on the sequence. You could just call <code>seq</code> on <code>s</code>. Lastly, because you are passing s to a seq consuming function anyway, you can elide the call to <code>seq</code> yourself.</p>
<p>This simplifies <code>my-reverse</code> down to:</p>
<p><code>(defn str-reverse [s] (reduce #(str %2 %) "" s)</code></p>
<p>An alternate formulation that takes advantage of lists building from the front might be</p>
<p><code>(defn str-reverse [s] (apply str (reduce conj () s)))</code></p>
<blockquote><p>
I think that in order to fully embrace the concept of functional programming is to use the three functions: map, reduce and filter extensively, and so I insisted on using them to tackle the problem.
</p></blockquote>
<p>Another fun variation of this is to use <code>juxt</code>, <code>partial</code> and <code>comp</code>:</p>
<p><code>(def palindrome? (comp (partial apply =) (juxt seq (partial reduce conj ()))))</code></p>
<img src="http://feeds.feedburner.com/~r/blog-japila-pl-comments/~4/GKTGtHW6_-o" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blog.japila.pl/2012/02/todays-a-palindrome-how-to-check-palindromes-in-clojure/#comment-1009</feedburner:origLink></item>
	<item>
		<title>Comment on Today’s a palindrome – how to check palindromes in Clojure by Mark Engelberg</title>
		<link>http://feedproxy.google.com/~r/blog-japila-pl-comments/~3/3aSJRh92qjI/</link>
		<dc:creator>Mark Engelberg</dc:creator>
		<pubDate>Tue, 21 Feb 2012 23:57:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.japila.pl/?p=747#comment-1008</guid>
		<description>(defn is-palindrome? [s] (= (seq s) (reduce conj () s)))</description>
		<content:encoded><![CDATA[<p>(defn is-palindrome? [s] (= (seq s) (reduce conj () s)))</p>
<img src="http://feeds.feedburner.com/~r/blog-japila-pl-comments/~4/3aSJRh92qjI" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blog.japila.pl/2012/02/todays-a-palindrome-how-to-check-palindromes-in-clojure/#comment-1008</feedburner:origLink></item>
	<item>
		<title>Comment on AOT-compile all namespaces in a Clojure project – :aot :all in project.clj (leiningen) by Alex Ott</title>
		<link>http://feedproxy.google.com/~r/blog-japila-pl-comments/~3/nceQJn6LICQ/</link>
		<dc:creator>Alex Ott</dc:creator>
		<pubDate>Tue, 21 Feb 2012 18:23:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.japila.pl/?p=743#comment-1007</guid>
		<description>You can also specify regex as parameter for :compile option - it will compile only matched namespaces</description>
		<content:encoded><![CDATA[<p>You can also specify regex as parameter for :compile option &#8211; it will compile only matched namespaces</p>
<img src="http://feeds.feedburner.com/~r/blog-japila-pl-comments/~4/nceQJn6LICQ" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blog.japila.pl/2012/02/aot-compile-all-namespaces-in-a-clojure-project-aot-all-in-project-clj-leiningen/#comment-1007</feedburner:origLink></item>
	<item>
		<title>Comment on hangman with lein run, Incanter, and opencsv – Counterclockwise is here, too by Jacek Laskowski</title>
		<link>http://feedproxy.google.com/~r/blog-japila-pl-comments/~3/BEyY-jM71IY/</link>
		<dc:creator>Jacek Laskowski</dc:creator>
		<pubDate>Fri, 17 Feb 2012 14:39:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.japila.pl/?p=718#comment-994</guid>
		<description>I figured it out the hard way :) You should have seen how surprised I was when I saw it in project.clj. It's very productive to have you aboard.</description>
		<content:encoded><![CDATA[<p>I figured it out the hard way <img src='http://blog.japila.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  You should have seen how surprised I was when I saw it in project.clj. It&#8217;s very productive to have you aboard.</p>
<img src="http://feeds.feedburner.com/~r/blog-japila-pl-comments/~4/BEyY-jM71IY" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blog.japila.pl/2012/02/hangman-with-lein-run-incanter-and-opencsv-counterclockwise-is-here-too/#comment-994</feedburner:origLink></item>
	<item>
		<title>Comment on hangman with lein run, Incanter, and opencsv – Counterclockwise is here, too by Konrad Garus</title>
		<link>http://feedproxy.google.com/~r/blog-japila-pl-comments/~3/m8m0Z4J1Guw/</link>
		<dc:creator>Konrad Garus</dc:creator>
		<pubDate>Fri, 17 Feb 2012 10:18:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.japila.pl/?p=718#comment-993</guid>
		<description>Hint on eclipse: Look for lein eclipse. Create a lein project, go into its folder and run "lein eclipse". It will create or update the eclipse project with all dependencies in classpath etc.

It's already present in librarian and in fact that's how I work on the project.</description>
		<content:encoded><![CDATA[<p>Hint on eclipse: Look for lein eclipse. Create a lein project, go into its folder and run &#8220;lein eclipse&#8221;. It will create or update the eclipse project with all dependencies in classpath etc.</p>
<p>It&#8217;s already present in librarian and in fact that&#8217;s how I work on the project.</p>
<img src="http://feeds.feedburner.com/~r/blog-japila-pl-comments/~4/m8m0Z4J1Guw" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blog.japila.pl/2012/02/hangman-with-lein-run-incanter-and-opencsv-counterclockwise-is-here-too/#comment-993</feedburner:origLink></item>
	<item>
		<title>Comment on Clojure’s lein and clj-time to calculate my son’s age by clj-time and Joda Time to pretty-print my son’s age in Clojure | Japila :: verba docent, exempla trahunt</title>
		<link>http://feedproxy.google.com/~r/blog-japila-pl-comments/~3/MgIMsnkjQGg/</link>
		<dc:creator>clj-time and Joda Time to pretty-print my son’s age in Clojure | Japila :: verba docent, exempla trahunt</dc:creator>
		<pubDate>Thu, 16 Feb 2012 21:50:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.japila.pl/?p=710#comment-990</guid>
		<description>[...] Clojure’s lein and clj-time to calculate my son’s age I wrote about clj-time to help me calculate my son’s age. What I missed was how to display [...]</description>
		<content:encoded><![CDATA[<p>[...] Clojure’s lein and clj-time to calculate my son’s age I wrote about clj-time to help me calculate my son&#8217;s age. What I missed was how to display [...]</p>
<img src="http://feeds.feedburner.com/~r/blog-japila-pl-comments/~4/MgIMsnkjQGg" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blog.japila.pl/2012/02/clojures-lein-and-clj-time-to-calculate-my-sons-age/#comment-990</feedburner:origLink></item>
	<item>
		<title>Comment on Mastering lein run by (clojure.java.browse/browse-url “http://clojure.org”) | Japila :: verba docent, exempla trahunt</title>
		<link>http://feedproxy.google.com/~r/blog-japila-pl-comments/~3/-s7wrSLO6jE/</link>
		<dc:creator>(clojure.java.browse/browse-url “http://clojure.org”) | Japila :: verba docent, exempla trahunt</dc:creator>
		<pubDate>Wed, 15 Feb 2012 23:02:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.japila.pl/?p=726#comment-981</guid>
		<description>[...] While reviewing the sources of RESTful Clojure webapp skeleton w/Compojure, Ring, Enlive, and ClojureQL I found the clojure.java.browse namespace with the browse-url function I was looking for for some time. [...]</description>
		<content:encoded><![CDATA[<p>[...] While reviewing the sources of RESTful Clojure webapp skeleton w/Compojure, Ring, Enlive, and ClojureQL I found the clojure.java.browse namespace with the browse-url function I was looking for for some time. [...]</p>
<img src="http://feeds.feedburner.com/~r/blog-japila-pl-comments/~4/-s7wrSLO6jE" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blog.japila.pl/2012/02/mastering-lein-run/#comment-981</feedburner:origLink></item>
	<item>
		<title>Comment on Helping daughter and myself with Clojure by Manuel Paccagnella</title>
		<link>http://feedproxy.google.com/~r/blog-japila-pl-comments/~3/6pI-Ejfli1k/</link>
		<dc:creator>Manuel Paccagnella</dc:creator>
		<pubDate>Mon, 13 Feb 2012 21:06:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.japila.pl/?p=693#comment-979</guid>
		<description>BTW, I've incorporated some suggetions from the clojure mailing list in &lt;a href="https://bitbucket.org/manuelp/geo-quiz/src/256400ef7438/src/geo_quiz/core.clj" rel="nofollow"&gt;this&lt;/a&gt; version.</description>
		<content:encoded><![CDATA[<p>BTW, I&#8217;ve incorporated some suggetions from the clojure mailing list in <a href="https://bitbucket.org/manuelp/geo-quiz/src/256400ef7438/src/geo_quiz/core.clj" rel="nofollow">this</a> version.</p>
<img src="http://feeds.feedburner.com/~r/blog-japila-pl-comments/~4/6pI-Ejfli1k" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blog.japila.pl/2012/02/helping-daughter-and-myself-with-clojure/#comment-979</feedburner:origLink></item>
</channel>
</rss>

