Question: (a) Write a safe_zip_int function that takes two lists of integers and combines them into a list of pairs of ints If the two input

(a)

Write a safe_zip_int function that takes two lists of integers and combines them into a list of pairs of ints

If the two input list are of unequal lengths, return None

your method must be tail recursive.

For example,

safe_zip_int [1;2;3;5] [6;7;8;9] = Some [(1,6);(2,7);(3,8);(5,9)]

safe_zip_int [1] [2;4;6;8] = None

safe_zip_int (between 0 1000000) (between 0 1000000) does not stack overflow

Note: The between function is from the previous programming assignment 1.

You can use the between function from the previous assignment for testing purposes.

let rec safe_zip_int (ls1: int list) (ls2: int list) : ((int * int) list) option =

(b)

Write a function that produces the ith Pell number:

your function must be tail recursive, and needs to have the correct output up to integer overflow

pell 0 = 0

pell 1 = 1

pell 7 = 169

pell 1000000 does not stack overflow

let rec pell (i: int) : int =

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!