Generate cuboids

Generate cuboids

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 = 

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 = 

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 = 

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

(* create an hyper-cube *)
let hyper_cube = power_function mult_interval [[]];;
(* create the unit cube *)
let unit_cube = hyper_cube (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 = hyper_cube (interval (-1) 1) 2;;
val square_2 : int list list = [[-1; -1]; [-1; 1]; [1; -1]; [1; 1]]

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

mult_interval unit_cube square_2;;
mult_interval square_2 unit_cube;;

Why?