Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
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
([email protected])
2. Re: R?f. : [Haskell-beginners] a problem (Stephen Tetley)
3. R?f. : Re: R?f. : [Haskell-beginners] a problem
([email protected])
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: [email protected]
Subject: R?f. : [Haskell-beginners] a problem
To: Michael Mossey <[email protected]>
Cc: [email protected]
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
<[email protected]
ech.edu> Pour
Envoyé par : [email protected]
beginners-bounce cc
[email protected]
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
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
Message: 2
Date: Fri, 25 Jun 2010 16:36:53 +0100
From: Stephen Tetley <[email protected]>
Subject: Re: R?f. : [Haskell-beginners] a problem
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On 25 June 2010 14:33, <[email protected]> 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: [email protected]
Subject: R?f. : Re: R?f. : [Haskell-beginners] a problem
To: Stephen Tetley <[email protected]>
Cc: [email protected]
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
[email protected] [email protected]
Objet
Re: Réf. : [Haskell-beginners] a
25/06/2010 17:37 problem
On 25 June 2010 14:33, <[email protected]> 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
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
Message: 4
Date: Fri, 25 Jun 2010 17:12:03 +0100
From: Stephen Tetley <[email protected]>
Subject: Re: R?f. : Re: R?f. : [Haskell-beginners] a problem
Cc: [email protected]
Message-ID:
<[email protected]>
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
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 24, Issue 35
*****************************************