
Hello Stephen,
I've just look at your solution, it is better ;)
Stephen Tetley
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... _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners