<?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: Scala: Code Kata #2 &#8211; Karate Chop &#8211; Array Slicing Attempt</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/10/13/scala-code-kata-2-karate-chop-array-slicing-attempt/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/10/13/scala-code-kata-2-karate-chop-array-slicing-attempt/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:17:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Alan Kent</title>
		<link>http://www.markhneedham.com/blog/2009/10/13/scala-code-kata-2-karate-chop-array-slicing-attempt/comment-page-1/#comment-42636</link>
		<dc:creator>Alan Kent</dc:creator>
		<pubDate>Wed, 28 Jul 2010 05:35:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1726#comment-42636</guid>
		<description>Doesn&#039;t slice() return a copy of the sub-array  (and so would be slow)?  Should it be using .view(offset,len) instead?  (Or did slice() change in Scala 2.8 so it used to be fine, but now slice() returns a copy so view() should be used instead?)</description>
		<content:encoded><![CDATA[<p>Doesn&#8217;t slice() return a copy of the sub-array  (and so would be slow)?  Should it be using .view(offset,len) instead?  (Or did slice() change in Scala 2.8 so it used to be fine, but now slice() returns a copy so view() should be used instead?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Latest karate news &#8211; Scala: Code Kata #2 &#8211; Karate Chop &#8211; Array Slicing Attempt at Mark &#8230;</title>
		<link>http://www.markhneedham.com/blog/2009/10/13/scala-code-kata-2-karate-chop-array-slicing-attempt/comment-page-1/#comment-31763</link>
		<dc:creator>Latest karate news &#8211; Scala: Code Kata #2 &#8211; Karate Chop &#8211; Array Slicing Attempt at Mark &#8230;</dc:creator>
		<pubDate>Thu, 11 Feb 2010 03:23:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1726#comment-31763</guid>
		<description>[...] Scala: Code Kata #2 &#8211; Karate Chop &#8211; Array Slicing Attempt at Mark &#8230; [...]</description>
		<content:encoded><![CDATA[<p>[...] Scala: Code Kata #2 &#8211; Karate Chop &#8211; Array Slicing Attempt at Mark &#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/10/13/scala-code-kata-2-karate-chop-array-slicing-attempt/comment-page-1/#comment-24342</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Wed, 14 Oct 2009 13:30:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1726#comment-24342</guid>
		<description>@Raph - I really like that last bit of your solution where you pattern match on the recursive call, very cool. 

I&#039;m thinking of maybe trying this kata again and trying to make the tests pass as I go rather than hacking in the edge cases at the end to see what it comes up with.</description>
		<content:encoded><![CDATA[<p>@Raph &#8211; I really like that last bit of your solution where you pattern match on the recursive call, very cool. </p>
<p>I&#8217;m thinking of maybe trying this kata again and trying to make the tests pass as I go rather than hacking in the edge cases at the end to see what it comes up with.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tweets that mention Scala: Code Kata #2 – Karate Chop – Array Slicing Attempt at Mark Needham -- Topsy.com</title>
		<link>http://www.markhneedham.com/blog/2009/10/13/scala-code-kata-2-karate-chop-array-slicing-attempt/comment-page-1/#comment-24341</link>
		<dc:creator>Tweets that mention Scala: Code Kata #2 – Karate Chop – Array Slicing Attempt at Mark Needham -- Topsy.com</dc:creator>
		<pubDate>Wed, 14 Oct 2009 13:26:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1726#comment-24341</guid>
		<description>[...] This post was mentioned on Twitter by Mark Needham and Michael Norton, planettw. planettw said: Mark Needham: Scala: Code Kata #2 – Karate Chop – Array Slicing Attempt: In my continued attempts to learn a bi.. http://bit.ly/dcP16 [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was mentioned on Twitter by Mark Needham and Michael Norton, planettw. planettw said: Mark Needham: Scala: Code Kata #2 – Karate Chop – Array Slicing Attempt: In my continued attempts to learn a bi.. <a href="http://bit.ly/dcP16" rel="nofollow">http://bit.ly/dcP16</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raphael Speyer</title>
		<link>http://www.markhneedham.com/blog/2009/10/13/scala-code-kata-2-karate-chop-array-slicing-attempt/comment-page-1/#comment-24336</link>
		<dc:creator>Raphael Speyer</dc:creator>
		<pubDate>Wed, 14 Oct 2009 12:58:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1726#comment-24336</guid>
		<description>Oops, last post was killed by the angle brackets. I&#039;ll try again, but in any case I put the code here: http://gist.github.com/210041

def chop(needle : Int, haystack : Array[Int]) : Int = {
  if (haystack.length == 0) return -1
  val midPoint = haystack.length / 2
  val midValue = haystack(midPoint)

  if (midValue == needle) 
    midPoint
  else if (needle &lt; midValue) 
    chop(needle, haystack.slice(0, midPoint))
  else
    chop(needle, haystack.slice(midPoint + 1, haystack.length)) match {
      case -1     =&gt; -1
      case index =&gt; midPoint + 1 + index
    }
}</description>
		<content:encoded><![CDATA[<p>Oops, last post was killed by the angle brackets. I&#8217;ll try again, but in any case I put the code here: <a href="http://gist.github.com/210041" rel="nofollow">http://gist.github.com/210041</a></p>
<p>def chop(needle : Int, haystack : Array[Int]) : Int = {<br />
  if (haystack.length == 0) return -1<br />
  val midPoint = haystack.length / 2<br />
  val midValue = haystack(midPoint)</p>
<p>  if (midValue == needle)<br />
    midPoint<br />
  else if (needle &lt; midValue)<br />
    chop(needle, haystack.slice(0, midPoint))<br />
  else<br />
    chop(needle, haystack.slice(midPoint + 1, haystack.length)) match {<br />
      case -1     =&gt; -1<br />
      case index =&gt; midPoint + 1 + index<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raphael Speyer</title>
		<link>http://www.markhneedham.com/blog/2009/10/13/scala-code-kata-2-karate-chop-array-slicing-attempt/comment-page-1/#comment-24332</link>
		<dc:creator>Raphael Speyer</dc:creator>
		<pubDate>Wed, 14 Oct 2009 12:51:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1726#comment-24332</guid>
		<description>What about this?

def chop(needle : Int, haystack : Array[Int]) : Int = {
  if (haystack.length == 0) return -1
  val midPoint = haystack.length / 2
  val midValue = haystack(midPoint)

  if (midValue == needle) 
    midPoint
  else if (needle  -1
      case index =&gt; midPoint + 1 + index
    }
}

You can add the midPoint to the found index as the results are being returned up the call stack, rather than passing it as an argument on the way down.</description>
		<content:encoded><![CDATA[<p>What about this?</p>
<p>def chop(needle : Int, haystack : Array[Int]) : Int = {<br />
  if (haystack.length == 0) return -1<br />
  val midPoint = haystack.length / 2<br />
  val midValue = haystack(midPoint)</p>
<p>  if (midValue == needle)<br />
    midPoint<br />
  else if (needle  -1<br />
      case index =&gt; midPoint + 1 + index<br />
    }<br />
}</p>
<p>You can add the midPoint to the found index as the results are being returned up the call stack, rather than passing it as an argument on the way down.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

