Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write in Ocaml You should use todo functions This question involves two simple exercises in list manipulation. In the first one you are given a

Write in Ocaml

You should use todo functions

  1. This question involves two simple exercises in list manipulation. In the first one you are given a pair: the first member of the pair is an item and the second member is a list of items of the same type as the first member. The output is a boolean that says whether the item is in the list or not. The second function takes a pair of an item and a list and returns a list with the item removed. If the item is not in the list then the same list is returned. Here are the declarations and types.

    # let rec memberof pair = ... val memberof : 'a * 'a list -> bool =  # let rec remove (item, lst) = ... val remove : 'a * 'a list -> 'a list =  # remove (3, [1; 6; 3; 2; 6; 1; 7; 2; 3; 5]);; - : int list = [1; 6; 2; 6; 1; 7; 2; 5]

    The lists may contain duplicates; all copies should be removed. Make sure that you deal with empty lists. Even though your functions are polymorphic the grader cannot handle variant types in the mutation tester. So your test examples should all involve integers only. Here is an important style remark: never write if foo then true else false; this should just be foo.

(* Q2 TODO: Write your own tests for the memberof function. *) let memberof_tests = [ (* Your test cases go here. *) ]

(* Q2 TODO: Implement memberof. *) let rec memberof pair = raise NotImplemented ;;

(* (* Q2 TODO: Write your own tests for the remove function. *) let remove_tests = [ (* Your test cases go here. *) ]

(* Q2 TODO: Implement remove. *) let rec remove (item, lst) = raiseNotImplemented ;;

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_2

Step: 3

blur-text-image_3

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 And Expert Systems Applications Dexa 2021 Workshops Biokdd Iwcfs Mlkgraphs Al Cares Protime Alsys 2021 Virtual Event September 27 30 2021 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Anna Fensel ,Jorge Martinez-Gil ,Lukas Fischer

1st Edition

3030871002, 978-3030871000

More Books

Students also viewed these Databases questions

Question

3. List ways to manage relationship dynamics

Answered: 1 week ago