<p dir="ltr">Hi,</p>
<p dir="ltr">I don't see anything as a Prelude function, but you can do something with a combination of take and drop:</p>
<p dir="ltr">rangeOf:: Int -> Int -> [a]<br>
rangeOf x y = take y . drop x</p>
<p dir="ltr">rangeOf 2 4 [1 .. 5] -- [3,4,5]</p>
<p dir="ltr">I have not included any bounds check. It's up to you. For added benefits, look up dropWhile and takeWhile.</p>
<p dir="ltr">HTH.</p>
<div class="gmail_quot<blockquote class=" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi guys,<br>
As a newby to haskell, I was curious, what is the best way to splice an array or do things in the middle?<br>
For example, binary search requires i do in sudocode<br>
define binary search array target.<br>
Find middle element.<br>
If target is middle element then return target<br>
else if target < middle element then<br>
    binary search array[0:target]<br>
else<br>
    binary search array[target:end]<br>
<br>
How can I get this splicing with haskell?<br>
I can't just use head here.<br>
I can't do array!!n: where n is some number.<br>
<br>
Thanks,<br>
Derek<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</div>