<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IANP.ORG</title>
	<atom:link href="http://ianp.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://ianp.org</link>
	<description>random thought and mutterings</description>
	<lastBuildDate>Tue, 12 Jan 2010 19:00:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Vote Now!</title>
		<link>http://ianp.org/2010/01/vote-now/</link>
		<comments>http://ianp.org/2010/01/vote-now/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 19:00:22 +0000</pubDate>
		<dc:creator>Ian Phillips</dc:creator>
				<category><![CDATA[Trivia]]></category>
		<category><![CDATA[Barbie]]></category>
		<category><![CDATA[Vote]]></category>

		<guid isPermaLink="false">http://ianp.org/?p=493</guid>
		<description><![CDATA[Fed up with all of the pre-election coverage in the (UK) media right now? Instead of listening to call-me-Dave drone on and on, or hearing how the one-eyed Gobblin’ King has once again saved the world, go cast your vote for Computer Engineer&#160;Barbie!
]]></description>
			<content:encoded><![CDATA[<p>Fed up with all of the pre-election coverage in the (UK) media right now? Instead of listening to call-me-Dave drone on and on, or hearing how the one-eyed Gobblin’ King has once again saved the world, go cast your <a href="http://www.barbie.com/vote/">vote</a> for Computer Engineer&nbsp;Barbie!</p>
]]></content:encoded>
			<wfw:commentRss>http://ianp.org/2010/01/vote-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL: Just Say No!</title>
		<link>http://ianp.org/2010/01/sql-just-say-no/</link>
		<comments>http://ianp.org/2010/01/sql-just-say-no/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 16:29:30 +0000</pubDate>
		<dc:creator>Ian Phillips</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://ianp.org/?p=488</guid>
		<description><![CDATA[Just in time for the weekend, the SF NoSQL community have put up a collection of talks and slides from their recent get together. I’ll have more to say after I’ve had a chance to look these&#160;over…

Update: not actually a new set of talks, these have been online for about 6 months now, but it’s [...]]]></description>
			<content:encoded><![CDATA[<p>Just in time for the weekend, the SF <a href="http://en.wikipedia.org/wiki/NoSQL">NoSQL</a> community have put up a <a href="http://blog.oskarsson.nu/2009/06/nosql-debrief.html">collection of talks and slides</a> from their recent get together. I’ll have more to say after I’ve had a chance to look these&nbsp;over…</p>

<p><em>Update:</em> not actually a new set of talks, these have been online for about 6 months now, but it’s the first time that I’ve seen&nbsp;them…</p>
]]></content:encoded>
			<wfw:commentRss>http://ianp.org/2010/01/sql-just-say-no/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prevalent Synchronicity</title>
		<link>http://ianp.org/2010/01/prevalent-synchronicity/</link>
		<comments>http://ianp.org/2010/01/prevalent-synchronicity/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 13:23:33 +0000</pubDate>
		<dc:creator>Ian Phillips</dc:creator>
				<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Prevalent Systems]]></category>

		<guid isPermaLink="false">http://ianp.org/?p=486</guid>
		<description><![CDATA[Maybe it’s just an idea whose time has come, but in the past few days there’ve been 2 prevalent database systems announced for Clojure: FleetDB and&#160;Persister.

Prevalent&#160;Databases

The idea behind prevalent databases has been around for a while being, if not ‘popularised’ exactly, at least pushed by the guys behind Prevayler. Here’s how they describe&#160;them:


  Prevayler [...]]]></description>
			<content:encoded><![CDATA[<p>Maybe it’s just an idea whose time has come, but in the past few days there’ve been 2 prevalent database systems announced for <a href="http://clojure.org/">Clojure</a>: <a href="http://fleetdb.org/">FleetDB</a> and&nbsp;<a href="http://github.com/SergeyDidenko/Simple-Persistence-for-Clojure">Persister</a>.</p>

<h4>Prevalent&nbsp;Databases</h4>

<p>The idea behind prevalent databases has been around for a while being, if not ‘popularised’ exactly, at least pushed by the guys behind <a href="http://www.prevayler.org/">Prevayler</a>. Here’s how they describe&nbsp;them:</p>

<blockquote>
  <p>Prevayler is an open source object persistence library for Java. It is an implementation of the Prevalent System design pattern, in which business objects are kept live in memory and transactions are journaled for system&nbsp;recovery.</p>
</blockquote>

<h4>Fleet&nbsp;DB</h4>

<p>While <a href="http://twitter.com/mmcgrana">Mark McGranaghan</a>’s Fleet DB doesn’t use the term prevalent database, but right now that’s basically what it is. The core of Fleet DB is a Clojure based append-only log based database; it provides a native clojure query language (with built in query optimiser), schema-less records, indexes, and a server with a JSON based network&nbsp;protocol.</p>

<p>For a new new project Fleet DB also has a good set of documentation and it sounds like Mark has some big plans for it in the future. As an added benefit there are also clients for the network protocol in languages other than Clojure (Ruby officially, and a set of Python bindings in&nbsp;development).</p>

<h4>Persister</h4>

<p>Sergey Didenko’s <a href="http://github.com/SergeyDidenko/Simple-Persistence-for-Clojure">Simple Persistence for Clojure</a> project is a much less ambitious offering, but with the really cool feature of being a single (255 line, ~11KB) file that you could just drop into your project and start using - that’s pretty lightweight! From the read me&nbsp;file:</p>

<blockquote>
  <p>Simple Persistence for Clojure is a journal-based persistence library for Clojure programs. It follows “Prevalent system” design&nbsp;pattern.</p>
  
  <p>The intended usage is assist you in making a prevalent system. Thus you work with your in-memory data and wrap every writing call into one of (apply-transaction*)&nbsp;macros.</p>
</blockquote>

<p>A nice feature is that the log files are just Clojure&nbsp;code:</p>

<blockquote>
  <p>Transactions are logged as a valid Clojure code, so they are easy to read and run&nbsp;separately.</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ianp.org/2010/01/prevalent-synchronicity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Squeeze!</title>
		<link>http://ianp.org/2010/01/squeeze/</link>
		<comments>http://ianp.org/2010/01/squeeze/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 18:38:16 +0000</pubDate>
		<dc:creator>Ian Phillips</dc:creator>
				<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Clojure]]></category>

		<guid isPermaLink="false">http://ianp.org/?p=481</guid>
		<description><![CDATA[One of the neat features of Clojure is the sequence abstraction — it makes solving a whole host of data processing tasks much easier, simply get you data into a sequence and you&#8217;ve got a huge toolbox available to work on it. Of course being a guy I’m firmly of the belief that more tools are better, [...]]]></description>
			<content:encoded><![CDATA[<p>One of the neat features of <a href="http://clojure.org/">Clojure</a> is the <a href="http://clojure.org/sequences">sequence</a> abstraction — it makes solving a whole host of data processing tasks much easier, simply get you data into a sequence and you&#8217;ve got a huge toolbox available to work on it. Of course being a guy I’m firmly of the belief that more tools are better, with that in mind let’s add another one to our&nbsp;toolbox.</p>

<p>Given a sequence the squeeze function returns another sequence with any adjacent items which match a supplied predicate merged together using a supplied function. It’s probably easier to illustrate by example, suppose I have a sequence of strings and I want to merge them together when the trailing string starts with whitespace, I can squeeze them like&nbsp;this:</p>


<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>squeeze #<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">and</span> <span style="color: #66cc66;">%</span>2 <span style="color: #66cc66;">&#40;</span>re-matches #<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\A</span><span style="color: #000099; font-weight: bold;">\s</span>.*&quot;</span> <span style="color: #66cc66;">%</span>2<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
         #<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">apply</span> str <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">apply</span> concat <span style="color: #66cc66;">%&amp;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;hello&quot;</span> <span style="color: #ff0000;">&quot; world.&quot;</span> <span style="color: #ff0000;">&quot;foo&quot;</span> <span style="color: #ff0000;">&quot; bar&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>


<p>Another example, given a sequence of characters (read from an <code>InputStream</code> for example), I could group them into words by squeezing then thusly (the first line is just to remind you that calling <code>seq</code> on a string produces a sequence of&nbsp;characters):</p>


<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;">user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>seq <span style="color: #ff0000;">&quot;Cheers, chars!&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>\C \h \e \e \r \s \<span style="color: #66cc66;">,</span> \space \c \h \a \r \s \<span style="color: #66cc66;">!</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>map str/trim
         <span style="color: #66cc66;">&#40;</span>squeeze #<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">and</span> <span style="color: #66cc66;">%</span>2 <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span><span style="color: #66cc66;">=</span> \space <span style="color: #66cc66;">%</span>2<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                  #<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">apply</span> str <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">apply</span> concat <span style="color: #66cc66;">%&amp;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                   <span style="color: #66cc66;">&#40;</span>seq <span style="color: #ff0000;">&quot;I'm sorry Dave, I can't let you do that.&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;I'm&quot;</span> <span style="color: #ff0000;">&quot;sorry&quot;</span> <span style="color: #ff0000;">&quot;Dave,&quot;</span> <span style="color: #ff0000;">&quot;I&quot;</span> <span style="color: #ff0000;">&quot;can't&quot;</span> <span style="color: #ff0000;">&quot;let&quot;</span> <span style="color: #ff0000;">&quot;you&quot;</span> <span style="color: #ff0000;">&quot;do&quot;</span> <span style="color: #ff0000;">&quot;that.&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>


<p>So how does it work? Well, here&#8217;s the&nbsp;interface:</p>


<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>defn squeeze
  <span style="color: #66cc66;">&#91;</span>pred merge-fn coll<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span>squeeze- pred merge-fn coll <span style="color: #b1b100;">nil</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>


<p>And here&#8217;s the actual function that does the work, it&#8217;s declared private because I don’t want to expose the matched parameter to the outside&nbsp;world.</p>


<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>defn- squeeze-
  <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>pred merge-fn coll matched<span style="color: #66cc66;">&#93;</span>
    <span style="color: #66cc66;">&#40;</span>lazy-seq
      <span style="color: #66cc66;">&#40;</span>when-<span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#91;</span>s <span style="color: #66cc66;">&#40;</span>seq coll<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#91;</span>f <span style="color: #66cc66;">&#40;</span>first s<span style="color: #66cc66;">&#41;</span>
              s <span style="color: #66cc66;">&#40;</span>second s<span style="color: #66cc66;">&#41;</span>
              rest <span style="color: #66cc66;">&#40;</span>rest coll<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
          <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>pred f s<span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span>squeeze- pred merge-fn rest <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cons</span> f matched<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#91;</span>next <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> matched <span style="color: #66cc66;">&#40;</span>merge-fn <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cons</span> f <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">reverse</span> matched<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> f<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
              <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cons</span> next <span style="color: #66cc66;">&#40;</span>squeeze- pred merge-fn rest <span style="color: #b1b100;">nil</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>


<p>I should probably point out that all of this playing around with sequences was inspired by <a href="http://fulldisclojure.blogspot.com/">Sean Devlin</a>’s <a href="http://fulldisclojure.blogspot.com/2010/01/12-fn-proposal-same-multisame.html">excellent proposal</a> for some new sequence functions for Clojure&nbsp;1.2.</p>

<p>The full code for this is available <a href="/files/2010/01/squeeze.clj">here</a> (it’s just the above, but with an added doc comment on the <code>squeeze</code> function&nbsp;definition).</p>
]]></content:encoded>
			<wfw:commentRss>http://ianp.org/2010/01/squeeze/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with Java Arrays</title>
		<link>http://ianp.org/2010/01/working-with-java-arrays/</link>
		<comments>http://ianp.org/2010/01/working-with-java-arrays/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 14:23:44 +0000</pubDate>
		<dc:creator>Ian Phillips</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Interop]]></category>

		<guid isPermaLink="false">http://ianp.org/?p=473</guid>
		<description><![CDATA[One improvement that I&#8217;d like to see in Clojure is more examples in the doc strings (or maybe in a separate :example metadata item). Still, nothing to stop me building up a set of my&#160;own.

So, here are some simple examples of working with Java arrays in&#160;Clojure…

Given some sample&#160;data:


&#40;def my-list '&#40;1 2 3 4 5&#41;&#41;
&#40;def my-vector [...]]]></description>
			<content:encoded><![CDATA[<p>One improvement that I&#8217;d like to see in Clojure is more examples in the doc strings (or maybe in a separate <code>:example</code> metadata item). Still, nothing to stop me building up a set of my&nbsp;own.</p>

<p>So, here are some simple examples of working with Java arrays in&nbsp;Clojure…</p>

<p>Given some sample&nbsp;data:</p>


<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>def my-<span style="color: #b1b100;">list</span> '<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">4</span> <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>def my-vector <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">4</span> <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>def my-map <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">:</span><span style="color: #555;">a</span> <span style="color: #ff0000;">&quot;apple&quot;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">b</span> <span style="color: #ff0000;">&quot;banana&quot;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">c</span> <span style="color: #ff0000;">&quot;chopped liver&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>


<p>To convert to Java&nbsp;arrays:</p>


<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>to-<span style="color: #b1b100;">array</span> my-<span style="color: #b1b100;">list</span><span style="color: #66cc66;">&#41;</span>
#<span style="color: #66cc66;">&lt;</span>Object<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span>Ljava<span style="color: #66cc66;">.</span>lang<span style="color: #66cc66;">.</span>Object<span style="color: #808080; font-style: italic;">;@962522b&gt;</span>
<span style="color: #66cc66;">&#40;</span>to-<span style="color: #b1b100;">array</span> my-vector<span style="color: #66cc66;">&#41;</span>
#<span style="color: #66cc66;">&lt;</span>Object<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span>Ljava<span style="color: #66cc66;">.</span>lang<span style="color: #66cc66;">.</span>Object<span style="color: #808080; font-style: italic;">;@37e55794&gt;</span>
<span style="color: #66cc66;">&#40;</span>to-<span style="color: #b1b100;">array</span> my-map<span style="color: #66cc66;">&#41;</span>
#<span style="color: #66cc66;">&lt;</span>Object<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span>Ljava<span style="color: #66cc66;">.</span>lang<span style="color: #66cc66;">.</span>Object<span style="color: #808080; font-style: italic;">;@52cd19d&gt;</span></pre></div></div>


<p>Note that this always returns <code>Object[]</code> regardless of the contents of the collection. Note also that the map isn&#8217;t flattened (the pp function used here is in&nbsp;<code>clojure.contrib.pprint</code>):</p>


<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;">user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>pp<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">:</span><span style="color: #555;">a</span> <span style="color: #ff0000;">&quot;apple&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">:</span><span style="color: #555;">b</span> <span style="color: #ff0000;">&quot;banana&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">:</span><span style="color: #555;">c</span> <span style="color: #ff0000;">&quot;chopped liver&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span></pre></div></div>


<p>If the array is 2-dimensional there is a corresponding&nbsp;function:</p>


<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;">user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>def my-vec-2d <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span> <span style="color: #cc66cc;">5</span> <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">7</span> <span style="color: #cc66cc;">8</span> <span style="color: #cc66cc;">9</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
#'user/my-vec-2d
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>to-array-2d my-vec-2d<span style="color: #66cc66;">&#41;</span>
#<span style="color: #66cc66;">&lt;</span>Object<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>Ljava<span style="color: #66cc66;">.</span>lang<span style="color: #66cc66;">.</span>Object<span style="color: #808080; font-style: italic;">;@3a42f352&gt;</span>
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>pp<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">9</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #b1b100;">nil</span></pre></div></div>


<p>If you need to use a specific type of array (e.g. to pass a <code>String[]</code> into a Java method) or need to use an array with more than 3 dimensions it&#8217;s a little&nbsp;trickier:</p>


<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;">user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>into-<span style="color: #b1b100;">array</span> my-<span style="color: #b1b100;">list</span><span style="color: #66cc66;">&#41;</span>
#<span style="color: #66cc66;">&lt;</span>Integer<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span>Ljava<span style="color: #66cc66;">.</span>lang<span style="color: #66cc66;">.</span><span style="color: #b1b100;">Integer</span><span style="color: #808080; font-style: italic;">;@60c0c8b5&gt;</span>
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>pp<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #b1b100;">nil</span>
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>into-<span style="color: #b1b100;">array</span> my-vector<span style="color: #66cc66;">&#41;</span>
#<span style="color: #66cc66;">&lt;</span>Integer<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span>Ljava<span style="color: #66cc66;">.</span>lang<span style="color: #66cc66;">.</span><span style="color: #b1b100;">Integer</span><span style="color: #808080; font-style: italic;">;@2151b0a5&gt;</span>
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>pp<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #b1b100;">nil</span>
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>into-<span style="color: #b1b100;">array</span> my-map<span style="color: #66cc66;">&#41;</span>
#<span style="color: #66cc66;">&lt;</span>MapEntry<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span>Lclojure<span style="color: #66cc66;">.</span>lang<span style="color: #66cc66;">.</span>MapEntry<span style="color: #808080; font-style: italic;">;@7ae0c7c3&gt;</span>
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>into-<span style="color: #b1b100;">array</span> <span style="color: #66cc66;">&#40;</span>vals my-map<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
#<span style="color: #66cc66;">&lt;</span>String<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span>Ljava<span style="color: #66cc66;">.</span>lang<span style="color: #66cc66;">.</span>String<span style="color: #808080; font-style: italic;">;@731de9b&gt;</span>
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>pp<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;apple&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;banana&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;chopped liver&quot;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #b1b100;">nil</span></pre></div></div>


<p>There, that should serve as a handy reference for myself for when I’m feeling&nbsp;forgetful…</p>
]]></content:encoded>
			<wfw:commentRss>http://ianp.org/2010/01/working-with-java-arrays/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Nexus One Launch Even on Jan 5?</title>
		<link>http://ianp.org/2009/12/nexus-one-launch-even-on-jan-5/</link>
		<comments>http://ianp.org/2009/12/nexus-one-launch-even-on-jan-5/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 19:13:26 +0000</pubDate>
		<dc:creator>Ian Phillips</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://ianp.org/?p=471</guid>
		<description><![CDATA[
  This just in: Google will host an Android press gathering at its global HQ on Jan. 5 …. Presumably, the event will have something to do with the company’s Nexus One, an Android phone that Google plans to sell on its own Web site and perhaps through T-Mobile as&#160;well.


via Digital&#160;Daily
]]></description>
			<content:encoded><![CDATA[<blockquote>
  <p>This just in: <a href="http://www.google.com/">Google</a> will host an <a href="http://www.android.com/">Android</a> press gathering at its global HQ on Jan. 5 …. Presumably, the event will have something to do with the company’s Nexus One, an Android phone that Google plans to sell on its own Web site and perhaps through T-Mobile as&nbsp;well.</p>
</blockquote>

<p>via <a href="http://digitaldaily.allthingsd.com/20091229/google-announces-jan-5-android-event/">Digital&nbsp;Daily</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ianp.org/2009/12/nexus-one-launch-even-on-jan-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Everything is a File</title>
		<link>http://ianp.org/2009/12/why-everything-is-a-file/</link>
		<comments>http://ianp.org/2009/12/why-everything-is-a-file/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 17:54:29 +0000</pubDate>
		<dc:creator>Ian Phillips</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[File Systems]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://ianp.org/?p=469</guid>
		<description><![CDATA[One of the distinguishing characteristics of Unix is the philosophy that “everything is a file” (taken even further in Linux and Plan 9). Reading the interview with Ken Thompson in Coders at Work (page 465) sheds some light on why this is the&#160;case:


  Seibel: So you basically wrote an OS so you’d have a [...]]]></description>
			<content:encoded><![CDATA[<p>One of the <a href="http://en.wikipedia.org/wiki/Unix_architecture">distinguishing characteristics of Unix</a> is the philosophy that “everything is a file” (taken even further in <a href="http://en.wikipedia.org/wiki/Linux">Linux</a> and <a href="http://plan9.bell-labs.com/plan9/">Plan 9</a>). Reading the interview with <a href="http://en.wikipedia.org/wiki/Ken_Thompson">Ken Thompson</a> in <a href="http://www.codersatwork.com/">Coders at Work</a> (page 465) sheds some light on why this is the&nbsp;case:</p>

<blockquote>
  <p><em>Seibel:</em> So you basically wrote an OS so you’d have a better environment to test your file&nbsp;system.</p>
  
  <p><em>Thompson:</em> Yes. Halfway through there that I realized it was a real time-sharing system. I was writing the shell to drive the file system. And then I was writing a couple other programs that drove the file system. And right about there I said, “All I need is an editor and I’ve got an operating&nbsp;system.”</p>
</blockquote>

<p>So Unix started life as a glorified test harness for Ken’s file system!&nbsp;Amusing…</p>
]]></content:encoded>
			<wfw:commentRss>http://ianp.org/2009/12/why-everything-is-a-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The C Programming Language</title>
		<link>http://ianp.org/2009/12/the-c-programming-language/</link>
		<comments>http://ianp.org/2009/12/the-c-programming-language/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 19:07:09 +0000</pubDate>
		<dc:creator>Ian Phillips</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Trivia]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Cthulhu]]></category>
		<category><![CDATA[Humour]]></category>

		<guid isPermaLink="false">http://ianp.org/?p=467</guid>
		<description><![CDATA[
  C functions may be used recursively; that is, a function may call itself either directly or indirectly. Uninquiring souls may take this as just another peculiarity of those C folk, of whose ways their neighbours speak little to outsiders but much among&#160;themselves.


By Kernighan, Ritchie, and&#160;Lovecraft
]]></description>
			<content:encoded><![CDATA[<blockquote>
  <p>C functions may be used recursively; that is, a function may call itself either directly or indirectly. Uninquiring souls may take this as just another peculiarity of those C folk, of whose ways their neighbours speak little to outsiders but much among&nbsp;themselves.</p>
</blockquote>

<p>By <a href="http://www.bobhobbs.com/files/kr_lovecraft.html">Kernighan, Ritchie, and&nbsp;Lovecraft</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ianp.org/2009/12/the-c-programming-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paredit.el Comes to IntelliJ</title>
		<link>http://ianp.org/2009/12/paredit-el-comes-to-intellij/</link>
		<comments>http://ianp.org/2009/12/paredit-el-comes-to-intellij/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 20:21:47 +0000</pubDate>
		<dc:creator>Ian Phillips</dc:creator>
				<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[IntelliJ]]></category>

		<guid isPermaLink="false">http://ianp.org/?p=465</guid>
		<description><![CDATA[I’ve been working on adding paredit.el like structural editing to the next version of the La Clojure plugin for Intellij IDEA. IDEA already does most of the paren matching stuff (automatically inserting a closing paren when you type an opening paren and so on). So far I’ve got the basic barf and slurp commands working, [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been working on adding <a href="http://mumble.net/~campbell/emacs/paredit.el">paredit.el</a> like structural editing to the next version of the <a href="http://plugins.intellij.net/plugin/?id=4050">La Clojure</a> plugin for <a href="http://www.jetbrains.com/idea/index.html">Intellij IDEA</a>. IDEA already does most of the paren matching stuff (automatically inserting a closing paren when you type an opening paren and so on). So far I’ve got the basic barf and slurp commands working, and splicing, as you can see in the screenshot&nbsp;below:</p>

<p><img src="/images/2009/12/idea-slurp-and-barf.png" alt="Slurping and Barfing" /></p>

<p>The next step is probably to make IDEA’s expand selection code be a little smarter in the face of&nbsp;s-expressions.</p>

<p>In related news: I found a good <a href="http://www.slideshare.net/mudphone/paredit-preso">introduction to paredit.el</a> on <a href="http://www.slideshare.net/">SlideShare</a> which may be of&nbsp;interest.</p>

<p>I’ll try to get the guys at IntelliJ to push out a new version of the plugin after the 9.0.1 release is out (it’s in beta&nbsp;now).</p>
]]></content:encoded>
			<wfw:commentRss>http://ianp.org/2009/12/paredit-el-comes-to-intellij/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clojure Purists?</title>
		<link>http://ianp.org/2009/12/clojure-purists/</link>
		<comments>http://ianp.org/2009/12/clojure-purists/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 14:39:25 +0000</pubDate>
		<dc:creator>Ian Phillips</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Concurrency]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://ianp.org/?p=463</guid>
		<description><![CDATA[I’ve been following Tim Bray’s excellent Concur.next article series covering approaches to concurrency in various languages, and currently (no pun intended!) covering Clojure. The latest article talks about a super efficient log parsing implementation done by Alex Osborne an includes the following&#160;comment:


  “Lots of the performance wins come from dipping into Java-land (AtomicLongs, LinkedBlockingQueue), [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been following <a href="http://www.tbray.org/ongoing/">Tim Bray</a>’s excellent <a href="http://www.tbray.org/ongoing/When/200x/2009/09/27/Concur-dot-next">Concur.next</a> article series covering approaches to concurrency in various languages, and currently (no pun intended!) covering Clojure. The <a href="http://www.tbray.org/ongoing/When/200x/2009/12/15/Osborne-WF2-Clojure">latest article</a> talks about a super efficient log parsing <a href="http://meshy.org/2009/12/13/widefinder-2-with-clojure.html">implementation</a> done by <a href="http://meshy.org/">Alex Osborne</a> an includes the following&nbsp;comment:</p>

<blockquote>
  <p>“Lots of the performance wins come from dipping into Java-land (AtomicLongs, LinkedBlockingQueue), which is perfectly OK, but a Clojure purist would probably see those occasions as maybe highlighting gaps in that language’s&nbsp;coverage.”</p>
</blockquote>

<p>I’d take issue with that, one of the real strengths of Clojure it that it has easy and fast access to the whole Java ecosystem. As <a href="http://clojure.org/jvm_hosted">Rich&nbsp;says</a>:</p>

<blockquote>
  <p>“Clojure is designed to be a hosted language, sharing the JVM type system, GC, threads etc. It compiles all functions to JVM bytecode. Clojure is a great Java library consumer, offering the dot-target-member notation for calls to&nbsp;Java.”</p>
</blockquote>

<p>That seems pretty clear to me. I wonder if the people claiming to be Clojure purists are all coming from a Lisp background rather than the Java&nbsp;world?</p>
]]></content:encoded>
			<wfw:commentRss>http://ianp.org/2009/12/clojure-purists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
