Generate rectangular parallelepipeds

Generate rectangular parallelepipeds

a) Let mult be a product function and unit be its neutral element. Implement the power_function that uses this product:

let rec power_function mult unit x n = ... ;;
val power_function : ('a -> 'a -> 'a) -> 'a -> 'a -> int -> 'a = <fun>

As exemples power_int and power_real are the n-th power of respectively an int and a real:

let power_int = power_function ( * ) 1;;
let power_real = power_function ( *. ) 1.0;;

b) What is the cryptic following function ?

power_function (+) 0;;
- : int -> int -> int = <fun>

c) Let interval be the following function:

let interval min max = [[min];[max]];;

Implement mult_interval, a fonction that does an ad-hoc product of two intervals:

let rec mult_interval a b = ... ;;
val mult_interval : 'a list list -> 'a list list -> 'a list list = <fun>

The following uses-cases show you what this ad-hoc product mult_interval is supposed to be.

(* create an hyper-cube *)
let power_interval = power_function mult_interval [[]];;
(* create the unit cube *)
let unit_cube = power_interval (interval 0 1) 3;;
val unit_cube : int list list =
  [[0; 0; 0]; [0; 0; 1]; [0; 1; 0]; [0; 1; 1]; [1; 0; 0]; [1; 0; 1];
   [1; 1; 0]; [1; 1; 1]]
(* create a square, origin-centered, size two *)
let square_2 = power_interval (interval (-1) 1) 2;;
val square_2 : int list list = [[-1; -1]; [-1; 1]; [1; -1]; [1; 1]]

d) Are the following two rectangular parallelepipeds the same one?

power_interval (interval 0 1) 6;;
power_interval unit_cube 2;;

e) Are the following two rectangular parallelepipeds the same one?

mult_interval unit_cube square_2;;
mult_interval square_2 unit_cube;;

Why?