
13 Aug
2011
13 Aug
'11
6:11 p.m.
Dennis Raddle
Can someone suggest an elegant way to write the following?
fn :: [Maybe Float] -> Maybe Float
in which, if the input list has all Nothing, then the result is Nothing if the input list has one or more Just x, then the result is Just x (in which the x is picked arbitrarily, could be the first one or last one)
Either of: fnFirst :: [Maybe a] -> Maybe a fnFirst = getFirst . mconcat . map First fnLast :: [Maybe a] -> Maybe a fnLast = getLast . mconcat . map Last Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://ertes.de/