<div dir="ltr"><div><div><div><div>David:<br></div>Thanks for putting me on the right track. This works:<br><br>    let twoListsTuple = case findIndex (\g -> (itemName g) == (itemName gradeItemP)) gradeItemList of<br>        Nothing -> (gradeItemList, [])<br>        Just x -> splitAt x gradeItemList<br><br></div>I was not sure if the splitAt function would take a Just Int in place of a regular Int without complaint, but that seems to be the case.<br></div><div>As it turns out, I can be certain from the context that the item will definitely be found in the list, but the case statement allows for the unpacking of the Maybe.<br></div><div><br></div>Thanks,<br><br></div>Geoffrey<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 27, 2015 at 4:16 PM, David McBride <span dir="ltr"><<a href="mailto:toad3k@gmail.com" target="_blank">toad3k@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>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"><div><div class="h5">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></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><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></div></div>_______________________________________________<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" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><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>