Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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. manipulating Map for music application (Dennis Raddle)
----------------------------------------------------------------------
Message: 1
Date: Fri, 6 Nov 2015 22:07:47 -0800
From: Dennis Raddle <[email protected]>
To: Haskell Beginners <[email protected]>
Subject: [Haskell-beginners] manipulating Map for music application
Message-ID:
<CAKxLvopdv7q7gu3L4erohWf8Ssqw_x-2=qzzbmvruqdhigs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I have a Haskell program that computes music compositions. A composition
consists of sounds that happen at locations. A location is data type Loc.
At each location is a list of chords. A chord is data type Chord. Each
chord contains some chord-specific data and a list of notes. A note is data
type Note.
So we have
data Note = Note ...
data Chord = Chord ChordSpecificData [Note]
type Composition = Map Loc [Chord]
I would like to write a few different functions that operate over all the
notes.
The following function breaks out all the notes, tupling them with the
associated Locs and Chords:
compositionToList :: Composition -> [(Loc,Chord,Note)]
The following function transforms Notes, keeping only the Just results. If
a Chord gets all its notes eliminated, that Chord is removed. If a Loc has
all its Chords removed, that Loc is removed from the Map.
mapNotesMaybe :: (Loc -> Chord -> Note -> Maybe Note) -> Composition
-> Composition
Any advice for concise code appreciated.
Dennis
What's a concise way of doing this?
Another useful function would be used for mapping
Dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151106/8cca5ff6/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 89, Issue 8
****************************************