[Haskell-beginners] inserting tupels inside list as tupels in list
byorgey at seas.upenn.edu
Fri Dec 18 17:58:12 EST 2009
On Fri, Dec 18, 2009 at 07:02:16PM +0100, kane96 at gmx.de wrote:
> maybe the subject is a little bit confusing :p
> I have a organiser list like that and have to add events (like panic, xmas, ...) which is also a type of tupel for a specific date:
> aliceOrg = [ ( (21,Dec,2009), [panic,aliceBDay] )
> ( (25,Dec,2009), [xmas] )
> ( (10,Jan,2010), [bobBDay] )
> What function(s) can I use to add these nested lists and tupels here?
You can use all the functions for manipulating lists and tuples in the
standard libraries... I'm not entirely sure what you are asking.
Let me suggest, however, that you probably don't want to be using
tuples so much; make your own data types. Something like this:
type Day = Int
data Month = Jan | Feb | ...
type Year = Int
data Date = Date Day Month Year
data CalEntry = CalEntry Date [Event]
data Event = ...
type Organizer = [CalEntry]
This is much less confusing since instead of just tuples everywhere
you have specific types that say exactly what the data represents.
More information about the Beginners