
I already have things like that: type Day = Int 17 data Month = Jan | Feb | Mar | Apr | May | Jun | Jul | Ago | Sep | Oct | Nov | Dec deriving (Eq,Enum,Show) type Year = Int type Date = (Day,Month,Year) type ID = Int type Event = (ID,String) type Organiser = [ (Date, [Event]) ] and now I should implement a function like this: addEvents :: Date -> [Event] -> Organiser -> Organiser that adds to an organiser a list of events for a specific date an example looks like this: xmas :: Event xmas = (2, "Christmas") aliceOrg :: Organiser aliceOrg = [ ( (21,Dec,2009), [panic,aliceBDay] ), ( (25,Dec,2009), [xmas] ) ] -------- Original-Nachricht --------
Datum: Fri, 18 Dec 2009 17:58:12 -0500 Von: Brent Yorgey
An: beginners@haskell.org Betreff: Re: [Haskell-beginners] inserting tupels inside list as tupels in list
On Fri, Dec 18, 2009 at 07:02:16PM +0100, kane96@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.
-Brent _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Preisknaller: GMX DSL Flatrate für nur 16,99 Euro/mtl.! http://portal.gmx.net/de/go/dsl02