Question: Scala language (functional lang.) b) (10 Points). Define a function altMap, which takes as parameter a list of functions (instead of the one function for

Scala language (functional lang.)

Scala language (functional lang.) b) (10 Points). Define a function altMap, which

b) (10 Points). Define a function altMap, which takes as parameter a list of functions (instead of the one function for map) to apply to a list. altMap applies the functions in the functions list to the elements of the list in order. In other words, it applies the first function to the first element, the second function to the second, and so on, until it is time to go back to applying the first function to the next element. For example, altMap (List(_ + 10,- + 100), List(0, 1, 2, 3, 4)) evaluates to List(10, 101, 12, 103, 14). Do not use built-in higher-order functions to implement altMap. c) [7 Points). Define function luhn for checking the validity of card numbers of arbitrary lengths using altMap. luhn should accept a list of Int values to represent the digits of the card. b) (10 Points). Define a function altMap, which takes as parameter a list of functions (instead of the one function for map) to apply to a list. altMap applies the functions in the functions list to the elements of the list in order. In other words, it applies the first function to the first element, the second function to the second, and so on, until it is time to go back to applying the first function to the next element. For example, altMap (List(_ + 10,- + 100), List(0, 1, 2, 3, 4)) evaluates to List(10, 101, 12, 103, 14). Do not use built-in higher-order functions to implement altMap. c) [7 Points). Define function luhn for checking the validity of card numbers of arbitrary lengths using altMap. luhn should accept a list of Int values to represent the digits of the card

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!