Basic exercises

Basic exercises

Write a function power of type int -> int -> int, which takes a and b two integers and returns a ^ b.

Write a function factorial of type int -> int, which takes n an integer and returns n!.

Arrays

Write a function print_int_array of type int array -> unit, which prints elements of an integer array, separated by \t.

Write a function sum of type int array -> int, which returns the sum of all elements of the array.

Lists

Write a function print_int_list and a function sum with the same goal but for lists.

Write a function filter of type ('a -> bool) -> 'a list -> 'a list, which takes a function (which takes an element of the list and returns true if the element should be kept) and a list.