haskell list of tuples PLEASE HELP!

hi,
I need to construct database using a list of 2-tuples. Database needs to contain information about one company owning another. Each fact representing a company x and a company y will appear as a tuple in database, with the owned company the second element of the tuple and the owning company the first element. For example: Company one owns company two, which owns company three which owns company four.
I did something like this:

database = ("company1","company2"):("company3","company4"):[]

I want to write an function to check if companyX owns companyY.

>owns "companyX" "companyY"
True

Is this correct way of setting database?
How should I start this function to show dependencies?


static86Asked:
Who is Participating?
 
fridomCEO/ProgrammerCommented:
See Tuples and Lists in Haskell put them together and you get:

you can use the  : to combine the tuples to a list however I'd prefer the  "simpler
[(tuple1), (tuple2)]

>How should I start this function to show dependencies?
What do you mean with this?
[("owner1", "company1"), ("owner2", "company2")]

that's the database

Then you can easily implement the finding with combining 
  length 
  filter 

access to  the tuples can be done this way:
let tuple = ("eins", 1)
(fst tuple) == "eins"
(snd tuple) == 1

Open in new window

0
 
static86Author Commented:
too late, but thanks:)!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.