Réf. : [Haskell-beginners] a problem

corentin.dupont at ext.mpsa.com corentin.dupont at ext.mpsa.com
Wed Jun 23 09:10:32 EDT 2010


Hello,
I've got (not that short):

conv :: Music_Data_ -> (Maybe Note, Maybe Direction, Maybe Sound)
conv (Music_Data_1 n) = (Just n, Nothing, Nothing)
conv (Music_Data_4 d) = (Nothing, Just d, Nothing)
conv (Music_Data_9 s) = (Nothing, Nothing, Just s)

sortOutMusicData :: [Music_Data_] -> ([Note],[Direction],[Sound])
sortOutMusicData d = catMaybes3 $ unzip3 $ map conv d

catMaybes3 (a,b,c) = (catMaybes a, catMaybes b, catMaybes c)


Cordialement,
Corentin DUPONT (SII)
CDL AL4/AT8 et Comelec
DTI/DPMO/CSEE/CLCO/LCTL
Tel: +33 (0) 1 56 47 65 38 / 47 65 38
corentin.dupont at ext.mpsa.com


                                                                           
             Michael Mossey                                                
             <mpm at alumni.calt                                              
             ech.edu>                                                 Pour 
             Envoyé par :              beginners at haskell.org               
             beginners-bounce                                           cc 
             s at haskell.org                                                 
                                                                     Objet 
                                       [Haskell-beginners] a problem       
             23/06/2010 10:08                                              
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Can I get a suggestion for a concise way to write 'sortOutMusicData' as
described here? This is MusicXML-related.

data Music_Data_ = Music_Data_1 Note
                  | Music_Data_4 Direction
                  | Music_Data_9 Sound
                   ...

sortOutMusicData :: [Music_Data_] -> ([Note],[Direction],[Sound])

_______________________________________________
Beginners mailing list
Beginners at haskell.org
http://www.haskell.org/mailman/listinfo/beginners




More information about the Beginners mailing list