Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ocaml Programing with obvious comments. 1. Write a function get_prefix_eq_int : int -> int list -> int list that returns a list consisting of only

Ocaml Programing with obvious comments.

1. Write a function get_prefix_eq_int : int -> int list -> int list that returns a list consisting of only the number that is its first argument; for as many as there are in the prefix to (start of) its second argument: get_prefix_eq_int 1 [1;1;3;4;1] = [1;1]. get_prefix_eq_int 2 [1;1;3;4;1] = []. get_prefix_eq_int 3 [3;3] = [3;3].

2. Write a function drop_prefix_eq_int : int -> int list -> int list that returns a list consisting of all elements in the second list with any occurrences of its first argument dropped at the start: drop_prefix_eq_int 1 [1;1;3;4;1] = [3;4;1]. drop_prefix_eq_int 2 [1;1;3;4;1] = [1;1;3;4;1]. drop_prefix_eq_int 3 [3;3] = [].

3. Write a function group_eq_int : int list -> int list list that returns a list of lists in which equal consecutive elements are grouped in a list. group_eq_int [1;1;3;4;1] = [[1;1];[3];[4];[1]]. group_eq_int [1;1;1;3;3;3;5;5;5;5] = [[1;1;1];[3;3;3];[5;5;5;5]].

4. Write a function group_eq : 'a list -> 'a list list that returns a list in which equal consecutive elements are grouped in a list. You might need some helper functions. group_eq [1;1;3;4;1] = [[1;1];[3];[4];[1]]. group_eq [1;1;1;3;3;3;5;5;5;5] = [[1;1;1];[3;3;3];[5;5;5;5]]. group_eq ["baby"; "shark"; "doo";"doo";"doo";"doo"] = [["baby"];["shark"];["doo";"doo";"doo";"doo"]].

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

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

Discuss what you think economics is concerned with addressing

Answered: 1 week ago