diff --git a/Algo/Courses/Chapter 6 - Lists (Exercises).md b/Algo/Courses/Chapter 6 - Lists (Exercises).md index c732d15..3348764 100644 --- a/Algo/Courses/Chapter 6 - Lists (Exercises).md +++ b/Algo/Courses/Chapter 6 - Lists (Exercises).md @@ -114,6 +114,16 @@ let maximum = function let rec arith_list n a1 r = if n <= 0 then [] else a1 :: arithmetic_list (n - 1) (a1 + r) r;; + +(*Other solution*) +# let arith_list n a1 r = + if n <= 0 then + invalid_arg "invalid rank n" + else + let rec f ai = function + | 0 -> [] + | i -> (a1+(n-i)+r)::f(ai+r) (i-1) + in f ai n;; ``` ## Exercise 2.2 @@ -121,3 +131,13 @@ let rec arith_list n a1 r = let concatenate_lists lst1 lst2 = lst1 @ lst2;; ``` + +## Exercise 3.1 +```Ocaml +let growing i = + if i = [] then false + else + let rec grow = + let e::t = i in + let test = e in + if e