
13 Aug
2011
13 Aug
'11
2:11 p.m.
On Sat, Aug 13, 2011 at 9:04 PM, 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)
I'd go by: fn l = let l' = filter (/= Nothing) l in if l' == [] then Nothing else head l' -- Mihai