<div dir="ltr"><div><div><div>You will probably do a case match on the result of findIndex to find out whether you want to split there. You will have to deal with the possibility that the item you are searching for is not in the list. Untested:<br><br></div>let twoListsTuple = case findIndex (\g -> (itemName g) == (itemName gradeItemP)) gradeItemList of<br></div> Nothing -> (gradeItemList,[])<br></div> Just newlists -> newlists<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 27, 2015 at 3:51 PM, Geoffrey Bays <span dir="ltr"><<a href="mailto:charioteer7@gmail.com" target="_blank">charioteer7@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Hi.<br>An elementary question here about two functions in Data.List:<br></div> how to use a value from findIndex which returns a Maybe Int,<br></div>and then use that result in splitAt which takes a regular Int?<br></div><div>This is in an IO() do<br></div><div><br></div>Like so: (This is in an IO() do block)<br><br> let gradeItemIndex = findIndex (\g -> (itemName g) == (itemName gradeItemP)) gradeItemList<br> let twoListsTuple = splitAt gradeItemIndex gradeItemList<br><br></div>// does not compile obviously<br><br></div>Many Thanks,<br><br></div>Geoffrey<br></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>