Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write these in Elixir Lab Description 1) isAscending?/1 - This function should return true if the elements of the input list are strictly ascending,

Please write these in Elixir

image text in transcribed

Lab Description 1) isAscending?/1 - This function should return true if the elements of the input list are strictly ascending, and false otherwise. Each element must be strictly larger than (not merely equal to) the element that precedes it. Note that the empty list is ascending, as is every list containing only a single element. 2) onlyOddDigits?/1 - This function should return true if the provided integer argument contains only odd digits (1,3,5,7,9) and false otherwise. Note that the digit ' 0 ' is considered even. Hint: The functions rem/2 and div/2 will serve you well here. 3) tailFib/1 - This function 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) ! 4) giveChange/2 - This function accepts an amount of money, and a list of coin values (in descending order). The function should return a list containing the minimum number of coins necessary to represent the money amount. The returned list should be in descending order. If it is not possible to make change for the amount with the provided list of coins, you should return the : er ror atom. Several examples are below. You may assume the coin values are provided such that the greedy solution will always be correct. Subtract the largest coin possible at each step. 5) reduce/3 - Consider MyEnum.reduce from the Elixir lecture slides. Lab4.reduce 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: Lab4. reduce ([1,2,3],fn(x,acc)x+acc end ) Lab4. reduce ([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 from the outside world as seen above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

=+What is the nature of the plant or site-level role of unions?

Answered: 1 week ago