Look also at <a href="http://hackage.haskell.org/package/safe">safe package</a><br><br><div class="gmail_quote">2012/3/13 Chris Wong <span dir="ltr">&lt;<a href="mailto:chrisyco%2Bhaskell-cafe@gmail.com">chrisyco+haskell-cafe@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, Mar 13, 2012 at 12:24 PM, Chris Smith &lt;<a href="mailto:cdsmith@gmail.com">cdsmith@gmail.com</a>&gt; wrote:<br>

&gt; On Mon, Mar 12, 2012 at 3:14 PM, Kevin Clees &lt;<a href="mailto:k.clees@web.de">k.clees@web.de</a>&gt; wrote:<br>
&gt;&gt; Now my function looks like this:<br>
&gt;&gt;<br>
&gt;&gt; tmp:: [(Int, Int)] -&gt; Int -&gt; (Int, Int)<br>
&gt;&gt; tmp [] y = (0,0)<br>
&gt;&gt; tmp xs y = xs !! (y-1)<br>
&gt;<br>
&gt; Just a warning that this will still crash if the list is non-empty by<br>
&gt; the index exceeds the length.  That&#39;s because your function is no<br>
&gt; longer recursive, so you only catch the case where the top-level list<br>
&gt; is empty.  The drop function doesn&#39;t crash when dropping too many<br>
&gt; elements though, so you can do this and get a non-recursive function<br>
&gt; that&#39;s still total:<br>
&gt;<br>
&gt; tmp :: [(Int,Int)] -&gt; Int -&gt; (Int, Int)<br>
&gt; tmp xs y = case drop (y-1) xs of<br>
&gt;    []         -&gt; (0,0)<br>
&gt;    Just (x:_) -&gt; x<br>
<br>
</div>That last line should be<br>
<br>
    (x:_) -&gt; x<br>
<br>
without the &quot;Just&quot;. Hopefully that&#39;ll save a bit of confusion.<br>
<span class="HOEnZb"><font color="#888888"><br>
Chris<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
&gt; --<br>
&gt; Chris Smith<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Haskell-Cafe mailing list<br>
&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>