Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please code in OCaml language I have a type person that has a name (string), age (int), and hobbies (a list of strings). And I

Please code in OCaml language

I have a type person that has a name (string), age (int), and hobbies (a list of strings).image text in transcribed

And I have a type database (db) with a list of person

image text in transcribed

How would I implement a program for remove?

image text in transcribed

For example: if my database has the list of person

db1 = { database = [ {name = "Sidonie"; age = 20; hobbies = ["Gaming"]}; {name = "Ryan"; age = 18; hobbies = ["Legos"; "Gaming"]}; {name = "Arnold"; age = 34; hobbies = ["Skiing"; "Cooking"]}; {name = "Alice"; age = 25; hobbies = ["Gaming"; "jogging"]} ] }

How could I implement a remove "Alice" db1 where all instances of a person named "Alice" is removed (if there are two "Alice"s then both of them are removed, etc).

Or would I have to change how my database stores person information? You can use recursion and List library modules as well.

typeperson={name:string;age:int;hobbies:stringlist} type database ={db : person list } remove name database: - Type: person dbdb - Description: given a person's name and a database, remove all persons with the same name from the database and return the updated database. If no persons exist in the database with the same name as the given person, the database should not change. - Examples: db1= remove "Alice" db1 (db1 no longer contains Alice, db1 is now empty )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

Finding and scheduling appointments with new prospective clients.

Answered: 1 week ago