<br><div><span class="gmail_quote">On 9/11/07, <b class="gmail_sendername">PR Stanley</b> <<a href="mailto:email@example.com">firstname.lastname@example.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi<br>take 1000 [1..3] still yields [1,2,3]<br>I thought it was supposed to return an error.<br>Any ideas?<br>Thanks, Paul</blockquote><div><br>If for some reason you want a version that does return an error in that situation, you could do something like the following:
<br><br>take' n _ | (n <= 0) = <br>take' n  | (n > 0) = error "take': list too short"<br> | otherwise = <br>take' n (x:xs) = x : take' (n-1) xs<br></div><br>I'm not sure why you'd want that, though. The standard implementation gracefully handles all inputs, and usually turns out to be what you want. Really, if I were you, instead of making a version take' as above, I would just use the standard take but check for the length of the list in the places where it matters.