程序代写代做代考 (*

(*
Honor code comes here:

First Name:
Last Name:
BU ID:

I pledge that this program represents my own
program code and that I have coded on my own. I received
help from no one in designing and debugging my program.
I have read the course syllabus of CS 320 and have read the sections on Collaboration
and Academic Misconduct. I also understand that I may be asked to meet the instructor
or the TF for a follow up interview on Zoom. I may be asked to explain my solution in person and
may also ask you to solve a related problem.
*)

(* TODO: Write a quicksort function in OCaml that has the following function signature:
int list->int list

i.e., it takes in as input a list of integers and gives back
as input a list of integers.

So for example, if the input list is [6;7;1] you will then
return back a sorted list that is [1;6;7].

You can choose the first element of the input list
as the pivot element. The quicksort must use recursion

You can create as many helper methods as you like.

*)

let rec quicksort list=[]

(* We are providing you with the print_list function that you can use for printing of list
and we hope that you find it useful for debugging purposes.

The type signature of this function is

int list -> unit
*)

let rec print_list list=
match list with
[] -> ()
| e::l -> print_int e ; print_string ” ” ; print_list l

(* TODO: Write a function that takes in as input a list of tuples and returns back a string.
For instance if the input is [(1,2);(3,4);(5,6)]) then you would return back a string that is as follows:

[ (1,2) (3,4) (5,6) ]

The type signature of this method is:
(int*int) list-> string.
We are giving you some code that is incorrect and does not do what is expected from the description above.

1. Can you provide some comments in plain english what is it that the code is actually doing i.e., what is its type signature
and what is it actually printing on the console?

2. Correct the code so that it does what is expected from the description provided.
*)

let rec get_list_of_tuple_as_string list=
match list with
[] -> “”
| (e,h)::l -> “”

(*
TODO: Write a function called rep that takes in as input as two integers and returns back a list that contains e replicated
n times.

For example if n is 4 and e is 1 then you would return back a list [1;1;1;1]

The type signature of this method is: int ->int -> int list
*)
let rec rep n (e:int)=[]

(*
TODO: Write a function called stitch that has the following signature:
int list -> int list -> (int*int) list

i.e., it takes in as input two list of integers and stitches them together to product a list of tuples.
For instance if the two inputs are [1;2;3;5] and [6;7;8;9]
then the output is [(1,6);(2,7);(3,8);(5,9)]

If the two input list are of unequal lengths then you must just return back an empty list.
You must use recursion for this method.
*)
let rec stitch a b=[]

(*
TODO: Write a function called dotProduct that has the following signature:
int list -> int list -> int option

i.e., it takes in as input two list of integers and returns back the dot product of the two list.
For instance if the two inputs are [1;2;3;4] and [6;7;8;9]
then the output is 1*6+2*7+3*8+4*9 i.e. 80.

If the two list are of unequal lengths then you actually return back None

Because this method can return back an int or it can return back a None, the function signature of this method is:
int list -> int list -> int option

I will talk more about this in my Friday lecture.

You must use recursion for this method. You are free to use normal or tail recursion for this.
*)
let rec dotProduct x y=None

(*
TODO:
Write any starter code that you see fit to write here to test out your code.
*)