(*--------------------------------------------------------- YOUR NAME: STUDENT ID: ---------------------------------------------------------*) let rec foldl f x l = match l with | [] -> x | hd::tl -> foldl f (f x hd) tl let rec foldr f x l = match l with | [] -> x | hd::tl -> f hd (foldr f x tl) let subt x y = x - y let d1 = [ 10; 20; 30; 40; 50] (*--------------------------------------------------------- QUESTION #1: What is the output of the statement below? ANSWER: ---------------------------------------------------------*) let _ = let ans = foldl subt 0 [ 10; 20; 30; 40; 50] in print_int ans (*--------------------------------------------------------- QUESTION #2: What is the output of the statement below? ANSWER: ---------------------------------------------------------*) let _ = let ans = foldr subt 0 [ 10; 20; 30; 40; 50] in print_int ans (*--------------------------------------------------------- QUESTION #3: What is the output of the statement below? ANSWER: ---------------------------------------------------------*) let _ = let ans = foldl subt 1 [ 10; 20; 30; 40; 50] in print_int ans (*--------------------------------------------------------- QUESTION #4: Complete the last line of the function "for_all" below using foldl() or foldr(). ---------------------------------------------------------*) let for_all f l = let fn x e = x && (f e) in __________________________ let _ = let d = [ 2; 4; 6; 8; 10] in let f x = x mod 2 == 0 in let ans = for_all f d in print_string (string_of_bool ans) (***** true ******) (*--------------------------------------------------------- QUESTION #5: Change the above function "for_all" to "there_exists" such that the second statement outputs false. ---------------------------------------------------------*) let there_exists f l = _______________________ _______________________ let _ = let d = [ 2; 4; 6; 8; 10] in let f x = x mod 2 == 1 in let ans = there_exists f d in print_string (string_of_bool ans) (***** false ******) (*--------------------------------------------------------- QUESTION #6: Given a very long list, which would you use, foldl or foldr? Why? ANSWER: ---------------------------------------------------------*)