Question: please work with OCaml programing 1. Tail Recursion. Write a tail-recursive function split : a list -> a list * a list that takes a

please work with OCaml programing

1. Tail Recursion.

Write a tail-recursive function split : a list -> a list * a list that takes a list and returns a pair of lists such that for all l, (fst (split l)) @ (snd (split l)) is a permutation of l. That is, it splits a list into two lists and returns a pair of the two lists. The lengths of the two lists should differ by at most one.

For example, split [1;2;3;4;5] can return ([1;2;3], [4;5]) or ([1;3;5], [2; 4]) or ([5;3], [4;2;1]

but not ([], [1;2;3;4;5]) or ([1;2;3], [3;4;5]) or ([1], [5]).

Base Code:

(*>* Problem 1.1 *>*) let fact (n: int) : int = ImplementMe code here ;;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!