Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. R?f. : [Haskell-beginners] a problem (corentin.dup...@ext.mpsa.com) 2. Re: R?f. : [Haskell-beginners] a problem (Stephen Tetley) 3. R?f. : Re: R?f. : [Haskell-beginners] a problem (corentin.dup...@ext.mpsa.com) 4. Re: R?f. : Re: R?f. : [Haskell-beginners] a problem (Stephen Tetley) ---------------------------------------------------------------------- Message: 1 Date: Fri, 25 Jun 2010 15:33:09 +0200 From: corentin.dup...@ext.mpsa.com Subject: R?f. : [Haskell-beginners] a problem To: Michael Mossey <m...@alumni.caltech.edu> Cc: beginners@haskell.org Message-ID: <ofc3194bfc.b1ac7e8f-onc125774d.004a3f7b-c125774d.004a7...@mpsa.com> Content-Type: text/plain; charset=ISO-8859-1 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 Michael Mossey <m...@alumni.calt ech.edu> Pour Envoyé par : beginners@haskell.org beginners-bounce cc s...@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@haskell.org http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 2 Date: Fri, 25 Jun 2010 16:36:53 +0100 From: Stephen Tetley <stephen.tet...@gmail.com> Subject: Re: R?f. : [Haskell-beginners] a problem Cc: beginners@haskell.org Message-ID: <aanlktilbtlyrw7jhogtzaxsvezobvkpzg8xn1njxo...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On 25 June 2010 14:33, <corentin.dup...@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... ------------------------------ Message: 3 Date: Fri, 25 Jun 2010 18:01:25 +0200 From: corentin.dup...@ext.mpsa.com Subject: R?f. : Re: R?f. : [Haskell-beginners] a problem To: Stephen Tetley <stephen.tet...@gmail.com> Cc: beginners@haskell.org Message-ID: <of7cb52c5c.062676ad-onc125774d.0057e509-c125774d.00580...@mpsa.com> Content-Type: text/plain; charset=ISO-8859-1 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...@haskell.org beginners@haskell.org Objet Re: Réf. : [Haskell-beginners] a 25/06/2010 17:37 problem On 25 June 2010 14:33, <corentin.dup...@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@haskell.org http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 4 Date: Fri, 25 Jun 2010 17:12:03 +0100 From: Stephen Tetley <stephen.tet...@gmail.com> Subject: Re: R?f. : Re: R?f. : [Haskell-beginners] a problem Cc: beginners@haskell.org Message-ID: <aanlktildfp6gxb--mbed_fnvwa6p1jngjlejqsmvq...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi Corentin Thanks - I wasn't meaning to bash your solution outright, but sometimes a points free or "chain-of-compose" style solution is less efficient and more long winded than using direct recursion or a fold. I'd contend this is one such case. ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 24, Issue 35 *****************************************