Create an Elixir source file called Lab4.ex. In this file you will define a module named Lab4. For the problems below, you will implement tail recursive functions. You must implement your own tail recursive functions. No built-in shortcuts, no indexing, no iteration. Your functions must call themselves in some recursive fashion. Unless otherwise specified, input lists may contain any combination of types, and be of arbitrary length. Assume nothing!
i) sumEven – Return the sum of all even integers in an input list.
ii) sumNum – Returns the sum of all numeric values in the list.
iii) tailFib – accepts an integer argument, n, and returns the nth Fibonacci number.
Assume the first two Fibonacci numbers are 1 and 1. That is, tailFib(1) == 1, tailFib(2)
== 1. There is no tailFib(0). Your tail-recursive implementation must avoid the
double recursive call. No O(2n)!
iv) reduce – Consider [login to view URL] from this week’s lecture. [login to view URL] will build on this. You will add an implementation that handles the optional 3rd argument to initialize acc. For example – the following two examples, exactly as written, should work correctly:
[login to view URL]([1, 2, 3], fn(x, acc) -> x+acc end)
[login to view URL]([1, 2, 3], 10, fn(x, acc) -> x+acc end)
You may use helper functions if you wish, so long as the user can invoke your
function as seen above.