Réf. : Re: Réf. : [Haskell-beginners] a problem
corentin.dupont at ext.mpsa.com
corentin.dupont at ext.mpsa.com
Fri Jun 25 12:01:25 EDT 2010
Hello Stephen,
I've just look at your solution, it is better ;)
Stephen Tetley
<stephen.tetley@
gmail.com> Pour
Envoyé par :
beginners-bounce cc
s at haskell.org beginners at haskell.org
Objet
Re: Réf. : [Haskell-beginners] a
25/06/2010 17:37 problem
On 25 June 2010 14:33, <corentin.dupont at ext.mpsa.com> wrote:
> 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 at haskell.org
http://www.haskell.org/mailman/listinfo/beginners
More information about the Beginners
mailing list