<?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: Binary Search in Haskell</title>
	<atom:link href="http://www.jacobsheehy.com/technology/binary-search-in-haskell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jacobsheehy.com/technology/binary-search-in-haskell/</link>
	<description>Jacob's thoughts on technology, politics, and daily life.</description>
	<lastBuildDate>Thu, 11 Feb 2010 01:25:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Andrew</title>
		<link>http://www.jacobsheehy.com/technology/binary-search-in-haskell/comment-page-1/#comment-11207</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Sun, 06 Dec 2009 06:41:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.jacobsheehy.com/technology/binary-search-in-haskell/#comment-11207</guid>
		<description>You could make your function a tad more general:

binsearch :: (Ord a) =&gt; [a] -&gt; a -&gt; Int -&gt; Int -&gt; Maybe Int -- list, value, low, high, return int
binsearch xs value low high
   &#124; high  value  = binsearch xs value low (mid-1)
   &#124; xs!!mid &lt; value  = binsearch xs value (mid+1) high
   &#124; otherwise        = Just mid
   where
   mid = low + ((high - low) `div` 2)</description>
		<content:encoded><![CDATA[<p>You could make your function a tad more general:</p>
<p>binsearch :: (Ord a) =&gt; [a] -&gt; a -&gt; Int -&gt; Int -&gt; Maybe Int &#8212; list, value, low, high, return int<br />
binsearch xs value low high<br />
   | high  value  = binsearch xs value low (mid-1)<br />
   | xs!!mid &lt; value  = binsearch xs value (mid+1) high<br />
   | otherwise        = Just mid<br />
   where<br />
   mid = low + ((high &#8211; low) `div` 2)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
