<?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: Learning Clojure #13: Making my code suck less</title>
	<atom:link href="http://tech.puredanger.com/index.php/2010/03/14/learning-clojure-13-making-my-code-suck-less/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.puredanger.com/2010/03/14/learning-clojure-13-making-my-code-suck-less/</link>
	<description>Alex Miller&#039;s technical blog</description>
	<lastBuildDate>Mon, 06 Feb 2012 19:39:50 -0800</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
	<item>
		<title>By: Alex Miller</title>
		<link>http://tech.puredanger.com/2010/03/14/learning-clojure-13-making-my-code-suck-less/comment-page-1/#comment-290377</link>
		<dc:creator>Alex Miller</dc:creator>
		<pubDate>Fri, 22 Apr 2011 20:07:40 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/?p=831#comment-290377</guid>
		<description>@Steve: You&#039;re right on array-map of course.  I was thinking about the internal implementation which is backed by an array and indexed by ints but that&#039;s not relevant to the use of it which is arbitrary keys and values.  

I hadn&#039;t run across map-indexed at the time of this writing, but that&#039;s good stuff.

On (apply str (interpose &quot; &quot; ... ) ), that is basically the definition of clojure.string/join (except join uses the more efficient path of creating a StringBuilder).</description>
		<content:encoded><![CDATA[<p>@Steve: You&#8217;re right on array-map of course.  I was thinking about the internal implementation which is backed by an array and indexed by ints but that&#8217;s not relevant to the use of it which is arbitrary keys and values.  </p>
<p>I hadn&#8217;t run across map-indexed at the time of this writing, but that&#8217;s good stuff.</p>
<p>On (apply str (interpose &#8221; &#8221; &#8230; ) ), that is basically the definition of clojure.string/join (except join uses the more efficient path of creating a StringBuilder).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Miner</title>
		<link>http://tech.puredanger.com/2010/03/14/learning-clojure-13-making-my-code-suck-less/comment-page-1/#comment-290374</link>
		<dc:creator>Steve Miner</dc:creator>
		<pubDate>Fri, 22 Apr 2011 19:50:23 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/?p=831#comment-290374</guid>
		<description>An array-map is a map that preserves the order of the keys.  For small maps (less than 10 keys) it can be useful to have a guaranteed order (for seq, etc.).  (Your text implied that the keys had to be &quot;indexes&quot; which sounds confusing to me.)

With Clojure 1.2, you can use map-indexed to solve your original problem. interpose is good for handling the space in between clauses.

(defn make-clauses [props]
  (apply str (interpose &quot; &quot; (map-indexed  #(format &quot;make str with %s and %d.&quot; %2 %1) props))))</description>
		<content:encoded><![CDATA[<p>An array-map is a map that preserves the order of the keys.  For small maps (less than 10 keys) it can be useful to have a guaranteed order (for seq, etc.).  (Your text implied that the keys had to be &#8220;indexes&#8221; which sounds confusing to me.)</p>
<p>With Clojure 1.2, you can use map-indexed to solve your original problem. interpose is good for handling the space in between clauses.</p>
<p>(defn make-clauses [props]<br />
  (apply str (interpose &#8221; &#8221; (map-indexed  #(format &#8220;make str with %s and %d.&#8221; %2 %1) props))))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neal Ravindran</title>
		<link>http://tech.puredanger.com/2010/03/14/learning-clojure-13-making-my-code-suck-less/comment-page-1/#comment-192482</link>
		<dc:creator>Neal Ravindran</dc:creator>
		<pubDate>Fri, 02 Apr 2010 10:36:32 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/?p=831#comment-192482</guid>
		<description>While clojures are a good thing that enable us to write cute code ..it might be a bad thing for readability and maintainability(the after-life of code). Generally speaking...the guys who maintain code may not be an ace developer like the one who wrote it, but some entry-level guy with minimal java knowledge who may need some significant ramp-up time.

So in effect...I would not deviate from the usage of StringBuilder to build up a string...ever! :)</description>
		<content:encoded><![CDATA[<p>While clojures are a good thing that enable us to write cute code ..it might be a bad thing for readability and maintainability(the after-life of code). Generally speaking&#8230;the guys who maintain code may not be an ace developer like the one who wrote it, but some entry-level guy with minimal java knowledge who may need some significant ramp-up time.</p>
<p>So in effect&#8230;I would not deviate from the usage of StringBuilder to build up a string&#8230;ever! :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Janus</title>
		<link>http://tech.puredanger.com/2010/03/14/learning-clojure-13-making-my-code-suck-less/comment-page-1/#comment-191236</link>
		<dc:creator>Daniel Janus</dc:creator>
		<pubDate>Tue, 30 Mar 2010 19:56:42 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/?p=831#comment-191236</guid>
		<description>You could also use my clj-iter library and write something along the lines of:

(defn make-clauses-mac [props]
  (apply str
    (iter (for prop in props)
            (for i from 0)
            (collect (format &quot;make str with %s and %d. &quot; prop i)))))

the macroexpansion of which would be very similar to your initial example.</description>
		<content:encoded><![CDATA[<p>You could also use my clj-iter library and write something along the lines of:</p>
<p>(defn make-clauses-mac [props]<br />
  (apply str<br />
    (iter (for prop in props)<br />
            (for i from 0)<br />
            (collect (format &#8220;make str with %s and %d. &#8221; prop i)))))</p>
<p>the macroexpansion of which would be very similar to your initial example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mac</title>
		<link>http://tech.puredanger.com/2010/03/14/learning-clojure-13-making-my-code-suck-less/comment-page-1/#comment-187136</link>
		<dc:creator>Mac</dc:creator>
		<pubDate>Mon, 15 Mar 2010 15:34:12 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/?p=831#comment-187136</guid>
		<description>I prefer 

(use &#039;clojure.contrib.seq-utils)
(defn make-clauses-mac [props]
  (map #(str &quot;make str with &quot; (nth % 1) &quot; and &quot; (nth % 0) &quot;.&quot;) (indexed props)))


user=&gt; (make-clauses-mac &#039;(foo1 foo2 foo3))
(&quot;make str with foo1 and 0.&quot; &quot;make str with foo2 and 1.&quot; &quot;make str with foo3 and 2.&quot;)

I like map, because you can parallelize it easily by just switch to pmap. and indexed
returns a vector pair, which allows indexed access via nth in log32N hops.</description>
		<content:encoded><![CDATA[<p>I prefer </p>
<p>(use &#8216;clojure.contrib.seq-utils)<br />
(defn make-clauses-mac [props]<br />
  (map #(str &#8220;make str with &#8221; (nth % 1) &#8221; and &#8221; (nth % 0) &#8220;.&#8221;) (indexed props)))</p>
<p>user=&gt; (make-clauses-mac &#8216;(foo1 foo2 foo3))<br />
(&#8220;make str with foo1 and 0.&#8221; &#8220;make str with foo2 and 1.&#8221; &#8220;make str with foo3 and 2.&#8221;)</p>
<p>I like map, because you can parallelize it easily by just switch to pmap. and indexed<br />
returns a vector pair, which allows indexed access via nth in log32N hops.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

