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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
static86Author Commented:
too late, but thanks:)!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.