<?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"
	>

<channel>
	<title>バカな火星人</title>
	<atom:link href="http://martian.org/marty/feed/" rel="self" type="application/rss+xml" />
	<link>http://martian.org/marty</link>
	<description>Marty was here!</description>
	<pubDate>Wed, 20 Aug 2008 16:57:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>ジエフ君のため</title>
		<link>http://martian.org/marty/2008/08/21/%e3%82%b8%e3%82%a8%e3%83%95%e5%90%9b%e3%81%ae%e3%81%9f%e3%82%81/</link>
		<comments>http://martian.org/marty/2008/08/21/%e3%82%b8%e3%82%a8%e3%83%95%e5%90%9b%e3%81%ae%e3%81%9f%e3%82%81/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 16:57:45 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[日本語]]></category>

		<guid isPermaLink="false">http://martian.org/marty/?p=148</guid>
		<description><![CDATA[虫の歌
頭が溶けて
書こうかな
]]></description>
			<content:encoded><![CDATA[<p>虫の歌<br />
頭が溶けて<br />
書こうかな</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/08/21/%e3%82%b8%e3%82%a8%e3%83%95%e5%90%9b%e3%81%ae%e3%81%9f%e3%82%81/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Here be dragonfruits</title>
		<link>http://martian.org/marty/2008/08/19/here-be-dragonfruits/</link>
		<comments>http://martian.org/marty/2008/08/19/here-be-dragonfruits/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 14:59:39 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[food]]></category>

		<category><![CDATA[Japan]]></category>

		<guid isPermaLink="false">http://martian.org/marty/?p=139</guid>
		<description><![CDATA[Dragonfruit in Japan is bright purple on the inside.  SY wanted to see, since his Chinese dragonfruit, while larger, is grey inside.
]]></description>
			<content:encoded><![CDATA[<p>Dragonfruit in Japan is bright purple on the inside.  SY wanted to see, since his Chinese dragonfruit, while larger, is grey inside<div id="attachment_140" class="wp-caption alignnone" style="width: 310px"><a href="http://martian.org/marty/wp-content/uploads/2008/08/dragonfruit-closed.jpg"><img src="http://martian.org/marty/wp-content/uploads/2008/08/dragonfruit-closed-300x225.jpg" alt="unopened dragonfruit" title="dragonfruit" width="300" height="225" class="size-medium wp-image-140" /></a><p class="wp-caption-text">unopened dragonfruit</p></div><div id="attachment_141" class="wp-caption alignnone" style="width: 310px"><a href="http://martian.org/marty/wp-content/uploads/2008/08/dragonfruit-open.jpg"><img src="http://martian.org/marty/wp-content/uploads/2008/08/dragonfruit-open-300x225.jpg" alt="opened dragonfruit" title="dragonfruit-open" width="300" height="225" class="size-medium wp-image-141" /></a><p class="wp-caption-text">opened dragonfruit</p></div>.</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/08/19/here-be-dragonfruits/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Blog?</title>
		<link>http://martian.org/marty/2008/08/18/blog/</link>
		<comments>http://martian.org/marty/2008/08/18/blog/#comments</comments>
		<pubDate>Sun, 17 Aug 2008 15:16:28 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://martian.org/marty/?p=138</guid>
		<description><![CDATA[It&#8217;s that time of year again when I realise that I don&#8217;t actually write in this blog.
]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s that time of year again when I realise that I don&#8217;t actually write in this blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/08/18/blog/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Practical OCaml: larger example</title>
		<link>http://martian.org/marty/2008/03/23/practical-ocaml-larger-example/</link>
		<comments>http://martian.org/marty/2008/03/23/practical-ocaml-larger-example/#comments</comments>
		<pubDate>Sat, 22 Mar 2008 16:00:11 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[ocaml]]></category>

		<guid isPermaLink="false">http://martian.org/marty/2008/03/23/practical-ocaml-larger-example/</guid>
		<description><![CDATA[This &#34;Larger Example&#34; I&#8217;m going to write about is in chapter 18, starting on page 243.  The chapter is (supposed to be) about the object oriented features of OCaml (they would be the &#34;O&#34; part) but this example is more objectionable than objective.  It was intended to be an implementation of the Levenshtein [...]]]></description>
			<content:encoded><![CDATA[<p>This &quot;Larger Example&quot; I&#8217;m going to write about is in chapter 18, starting on page 243.  The chapter is (supposed to be) about the object oriented features of OCaml (they would be the &quot;O&quot; part) but this example is more objectionable than objective.  It was intended to be an implementation of the Levenshtein distance algorithm: it started with an incomplete description of that algorithm and a figure of a matrix with four mistakes.  Then it got worse.</p>
<p>Smith&#8217;s plan was to create a base class containing the algorithm and then use subclasses to adapt the algorithm to different data types.  But when I looked at the <code>edit_distance</code> base class I noticed that half of the core algorithm was missing!  I found it in the <code>string_edit_distance</code> subclass, and also in the <code>list_edit_distance</code> subclass.  Martin Fowler in his great &quot;<a href="http://martinfowler.com/books.html#refactoring">Refactoring</a>&quot; book says: <q>Number one in the stink parade is duplicated code.  If you see the same code structure in more than one place, you can be sure that your program will be better if you find a way to unify them.</q>  Following Fowler&#8217;s good advice, which Smith should have done, I moved the duplicated code to the base class.  There was only a small bit of code that was different for each subclass: the part that compares the elements of the particular data structures (strings and lists in this example) to work out if a changing cost is required.  I created a <code>cost_to_change</code> method to handle that.</p>
<p>Then I tried to simplify the code and make it more readable.</p>
<p>In the <code>update_matrix</code> method I removed three of the <i>let</i> bindings and passed the calculation results directly the <code>trimin</code> function I <a href="http://martian.org/marty/2008/03/22/practical-ocaml-not-again/">mentioned before</a>.</p>
<p>In the <code>gen_matrix</code> method I replaced the pattern matching and nested iteration functions with two separate iteration functions, which hopefully makes it clear that we are only initialising the first row and first column; most of the matrix is left untouched.</p>
<p>In the <code>calc</code> method, which I&#8217;d moved from the subclass to the base class, I again replaced the pattern matching and nested iteration functions, this time with nested <i>for</i> loops. Pattern matching and higher-order iteration functions are very powerful, and they could be used instead of loops and conditional statements in all ocaml code; but ocaml includes <i>for</i> loops and <i>if</i> statements because they are easier to use and understand than the more powerful features.  Choose the right tool for the job.</p>
<p>As a result of all these changes the size of a subclass has been reduced from 18 lines to 6, only 2 of which need to be changed for each data type (the other 4 are structure).  You can have a look at some of <a href="/marty/sample/ocaml-ch18.txt">Smith&#8217;s code</a> and <a href="/marty/sample/ocaml-my18.txt">my modified version</a> to see the differences for yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/03/23/practical-ocaml-larger-example/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Practical OCaml: not again</title>
		<link>http://martian.org/marty/2008/03/22/practical-ocaml-not-again/</link>
		<comments>http://martian.org/marty/2008/03/22/practical-ocaml-not-again/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 16:41:47 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[ocaml]]></category>

		<guid isPermaLink="false">http://martian.org/marty/2008/03/22/practical-ocaml-not-again/</guid>
		<description><![CDATA[I was about to comment on the &#34;Larger Example&#34; in chapter 18, starting on page 243; but first I have to get rid of the trimin method it contains:

    method private trimin x y z = match x,y,z with
        m,n,o when (m > n) -> [...]]]></description>
			<content:encoded><![CDATA[<p>I was about to comment on the &quot;Larger Example&quot; in chapter 18, starting on page 243; but first I have to get rid of the <code>trimin</code> method it contains:</p>
<pre>
    method private trimin x y z = match x,y,z with
        m,n,o when (m > n) -> if (n < o) then n else o
      | m,n,o when (m < n) -> if (m < o) then m else o
      | m,n,o -> if (n < o) then n else o
</pre>
<p>Let me now repeat exactly what I said in my <a href="http://martian.org/marty/2008/03/11/practical-ocaml-minimum-review/">previous post</a>: <strong>Huh?!</strong>  This method will return the smallest of its three arguments, although its ugliness made me doubt that for a while.  But even if it were improved, it shouldn&#8217;t even be part of this class at all.  So I removed that method and replaced it with a simple function:</p>
</pre>
<pre>let trimin x y z = min x (min y z);;</pre>
<p>That done, I was then able to continue with the &quot;larger example&quot;.</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/03/22/practical-ocaml-not-again/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Practical OCaml: minimum review</title>
		<link>http://martian.org/marty/2008/03/11/practical-ocaml-minimum-review/</link>
		<comments>http://martian.org/marty/2008/03/11/practical-ocaml-minimum-review/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 19:03:27 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[ocaml]]></category>

		<guid isPermaLink="false">http://martian.org/marty/2008/03/11/practical-ocaml-a-mimimum-review/</guid>
		<description><![CDATA[I have been reading Practical OCaml.  I didn&#8217;t buy the book; I recommend that you don&#8217;t buy it too.  I was given a copy and asked if I could say something good about it, so here goes: &#8220;it could be worse&#8221;.
There are so many other negative reviews of this book I don&#8217;t want [...]]]></description>
			<content:encoded><![CDATA[<p>I have been reading <a rel="nofollow" href="http://www.apress.com/book/view/159059620x">Practical OCaml</a>.  I didn&#8217;t buy the book; I recommend that you <em>don&#8217;t buy it</em> too.  I was given a copy and asked if I could say something good about it, so here goes: &#8220;it could be worse&#8221;.</p>
<p>There are so many other negative reviews of this book I don&#8217;t want to just repeat what has already been said.  Instead I&#8217;m going to criticise some parts of it in more detail in the hope that it may help.  I&#8217;m going to choose targets on a whim, with not much rhyme or reason; that should mirror the structure of the book quite well.</p>
<p>So, to start small, my first complaint is against page 172.  Smith (the book&#8217;s author) writes:</p>
<pre>
let min x y = match x with
    n when x &lt; y -&gt; x
  | _ -&gt; y;;
</pre>
<p><strong>Huh?!</strong></p>
<p>That can&#8217;t possibly be a sane way to define a function that returns the smaller of two arguments.  In addition to the needless complexity we have the unused named value <code>n</code>.  What was wrong with:</p>
<pre>
let min x y = if x &lt; y then x else y;;
</pre>
<p>That should be clear enough.  But I now have another question: why even bother?  The <code>min</code> function is built-in to OCaml; it is part of the <a href="http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html">Pervasives module</a> that provides &#8220;<code>&lt;</code>&#8221; and the other comparison operators.</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/03/11/practical-ocaml-minimum-review/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Winter advice</title>
		<link>http://martian.org/marty/2008/02/03/winter-advice/</link>
		<comments>http://martian.org/marty/2008/02/03/winter-advice/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 13:59:09 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://martian.org/marty/2008/02/03/winter-advice/</guid>
		<description><![CDATA[お勧めだ
黄色な雪を
食べないで
]]></description>
			<content:encoded><![CDATA[<p>お勧めだ<br />
黄色な雪を<br />
食べないで</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/02/03/winter-advice/feed/</wfw:commentRss>
		</item>
		<item>
		<title>YAPC::Asia 2008</title>
		<link>http://martian.org/marty/2008/01/30/yapcasia-2008/</link>
		<comments>http://martian.org/marty/2008/01/30/yapcasia-2008/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 15:22:43 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://martian.org/marty/2008/01/30/yapcasia-2008/</guid>
		<description><![CDATA[They must really want to make it easy for us to attend YAPC::Asia this year: the venue is beside our apartment!
]]></description>
			<content:encoded><![CDATA[<p>They must really want to make it easy for us to attend <a href="http://conferences.yapcasia.org/ya2008/">YAPC::Asia</a> this year: the venue is beside our apartment!</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/01/30/yapcasia-2008/feed/</wfw:commentRss>
		</item>
		<item>
		<title>There goes Godzilla&#8230;</title>
		<link>http://martian.org/marty/2008/01/22/there-goes-godzilla/</link>
		<comments>http://martian.org/marty/2008/01/22/there-goes-godzilla/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 17:35:48 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[日本語]]></category>

		<guid isPermaLink="false">http://martian.org/marty/2008/01/22/there-goes-godzilla/</guid>
		<description><![CDATA[In one of my Japanese classes I was studying transitivity pairs of verbs: in each pair both verbs have the same basic meaning, but one is transitive and the other is intransitive.  (A transitive verb requires an object; an intransitive verb does not.)  For example, one of the pairs was 「出す／出る」, which means [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my Japanese classes I was studying <i>transitivity pairs</i> of verbs: in each pair both verbs have the same basic meaning, but one is transitive and the other is intransitive.  (A transitive verb requires an object; an intransitive verb does not.)  For example, one of the pairs was 「出す／出る」, which means &#8220;take out / go out&#8221;: 「ごみを出す」 means &#8220;take out the trash&#8221;; 「出る」 means &#8220;I&#8217;m leaving&#8221;.</p>
<p>The textbook then described how the meanings would change in the present imperfect tense (the book didn&#8217;t call it that; it just called it the 「＋ている」 form).  Transitive verbs describe an action, so the present imperfect tense of a transitive verb describes an action in progress; this is a normal use in English.  But intransitive verbs describe a change, so the present imperfect tense of a intransitive verb describes a state that is the result of the change.  That made sense, and I hope it still does.</p>
<p>But then came the example sentences.  They are usually good examples that can be used in normal conversations, so I wasn&#8217;t surprised by the intransitive imperfect for &#8220;break&#8221;: 「このコンピューターは壊れています。」, meaning &#8220;this computer is broken&#8221;, is a useful phrase.  But the corresponding transitive example was 「ゴジラが町を壊しています。」 translated as &#8220;There goes Godzilla, destroying the city.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/01/22/there-goes-godzilla/feed/</wfw:commentRss>
		</item>
		<item>
		<title>No-brainer</title>
		<link>http://martian.org/marty/2008/01/19/no-brainer/</link>
		<comments>http://martian.org/marty/2008/01/19/no-brainer/#comments</comments>
		<pubDate>Fri, 18 Jan 2008 18:07:18 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://martian.org/marty/2008/01/19/no-brainer/</guid>
		<description><![CDATA[I&#8217;ve just been surprised and amused by an animated picture designed to identify the dominant side of your brain.  (I&#8217;m not going to post the image here as I cannot find any copyright details for it.  You can find it on many websites, including Gizmo Watch and Facebook.)  The picture shows a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just been surprised and amused by an animated picture designed to identify the dominant side of your brain.  (I&#8217;m not going to post the image here as I cannot find any copyright details for it.  You can find it on many websites, including <a href="http://www.gizmowatch.com/entry/left-vs-right-brain-test-for-creativity-or-logic/">Gizmo Watch</a> and Facebook.)  The picture shows a silhouetted dancer spinning, but the direction of spin, clockwise or anticlockwise, depends on your brain.</p>
<p>When I first saw the picture she was spinning clockwise, but when I started to read the text she immediately started spinning anticlockwise!  That makes perfect sense now, but it surprised me when it first happened; and it still amuses me every time I repeat it.</p>
<p>The explanation for the change in spin is quite simple: when I first look at the picture the right side of my brain tells me that she is spinning clockwise; but the left side of my brain (and your brain too) is responsible for reading, so when I start reading the left side kicks in and tells me that she is spinning anticlockwise; when I stop reading, she starts spinning clockwise again.</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/01/19/no-brainer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>道が長くて、駱駝が遅い</title>
		<link>http://martian.org/marty/2008/01/18/%e9%81%93%e3%81%8c%e9%95%b7%e3%81%8f%e3%81%a6%e3%80%81%e9%a7%b1%e9%a7%9d%e3%81%8c%e9%81%85%e3%81%84/</link>
		<comments>http://martian.org/marty/2008/01/18/%e9%81%93%e3%81%8c%e9%95%b7%e3%81%8f%e3%81%a6%e3%80%81%e9%a7%b1%e9%a7%9d%e3%81%8c%e9%81%85%e3%81%84/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 16:07:20 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Perl]]></category>

		<category><![CDATA[日本語]]></category>

		<guid isPermaLink="false">http://martian.org/marty/2008/01/17/%e9%81%93%e3%81%8c%e9%95%b7%e3%81%8f%e3%81%a6%e3%80%81%e9%a7%b1%e9%a7%9d%e3%81%8c%e9%81%85%e3%81%84/</guid>
		<description><![CDATA[Karen was reading Perl Buzz and noticed that Perl6 on Parrot will be called &#8220;Rakudo&#8221;, which is a shortened form of &#8220;rakudadou&#8221; or 駱駝道, the &#8220;way of the camel&#8221;.  But I think that &#8220;rokudo&#8221;, a shortened form of 六道輪廻, would be a better name; it even has the number 6 (六) at the start.
]]></description>
			<content:encoded><![CDATA[<p>Karen was reading <a href="http://perlbuzz.com/2008/01/perl-6-on-parrot-is-now-known-as-rakudo.html">Perl Buzz</a> and noticed that <a href="http://www.rakudo.org/2008/01/the-compiler-formerly-known-as.html">Perl6 on Parrot will be called &#8220;Rakudo&#8221;</a>, which is a shortened form of &#8220;rakudadou&#8221; or 駱駝道, the &#8220;way of the camel&#8221;.  But I think that &#8220;rokudo&#8221;, a shortened form of 六道輪廻, would be a better name; it even has the number 6 (六) at the start.</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/01/18/%e9%81%93%e3%81%8c%e9%95%b7%e3%81%8f%e3%81%a6%e3%80%81%e9%a7%b1%e9%a7%9d%e3%81%8c%e9%81%85%e3%81%84/feed/</wfw:commentRss>
		</item>
		<item>
		<title>It&#8217;s cold outside</title>
		<link>http://martian.org/marty/2008/01/16/its-cold-outside/</link>
		<comments>http://martian.org/marty/2008/01/16/its-cold-outside/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 13:30:16 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://martian.org/marty/2008/01/16/its-cold-outside/</guid>
		<description><![CDATA[Karen said, &#8220;It may actually be colder in the bathroom than it is outside&#8221;.  Well, it was actually the same temperature in the bathroom as it was outside, and I have just explained to Karen that doors and windows only provide some insulation when they are closed.
]]></description>
			<content:encoded><![CDATA[<p>Karen said, <a href="http://martian.org/karen/2008/01/16/too-cold/">&#8220;It may actually be colder in the bathroom than it is outside&#8221;</a>.  Well, it was actually the same temperature in the bathroom as it was outside, and I have just explained to Karen that doors and windows only provide some insulation when they are closed.</p>
]]></content:encoded>
			<wfw:commentRss>http://martian.org/marty/2008/01/16/its-cold-outside/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
