
25 Jun
2010
25 Jun
'10
3:36 p.m.
On 25 June 2010 14:33,
Hello, I would do (not that concise):
toMaybe :: Music_Data_ -> (Maybe Note, Maybe Direction, Maybe Sound) toMaybe (Music_Data_1 n) = (Just n, Nothing, Nothing) toMaybe (Music_Data_4 d) = (Nothing, Just d, Nothing) toMaybe (Music_Data_9 s) = (Nothing, Nothing, Just s)
catMaybes3 (a,b,c) = (catMaybes a, catMaybes b, catMaybes c)
sortOutMusicData :: [Music_Data_] -> ([Note],[Direction],[Sound]) sortOutMusicData = catMaybes3 . unzip3 . map toMaybe
Corentin
Hi Corentin Why would you do that though? It's doing quite a bit more work - introducing the extra constructors through the Nothing/Just's and extra traversals through the three catMaybe's in the post-processing step. And its longer too...