[Haskell-beginners] Using findIndex and then splitAt in Data.List

Geoffrey Bays charioteer7 at gmail.com
Fri Feb 27 20:51:12 UTC 2015


Hi.
An elementary question here about two functions in Data.List:
 how to use a value from findIndex which returns a Maybe Int,
and then use that result in splitAt which takes a regular Int?
This is in an IO() do

Like so: (This is in an IO() do block)

    let gradeItemIndex = findIndex (\g -> (itemName g) == (itemName
gradeItemP)) gradeItemList
    let twoListsTuple = splitAt  gradeItemIndex gradeItemList

// does not compile obviously

Many Thanks,

Geoffrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150227/cf140870/attachment.html>


More information about the Beginners mailing list