Trying to do this lab exercise with no luck…can someone help me please
ListHigherOrderFunction
takes an integer input from command line. Based on the input, write code to generate a list intList
, upto given integer starting from 1
i.e when input is 3
, List(1,2,3)
must be generated. Write a function factorial
which gives the factorial of a given number using recursion. Write a higher order function myHigherOrderFunction
which takes factorial
function and intList
which prints the factorial of each integer in the intList
Copy the following ListHigherOrderFunction program into the file:
object ListHigherOrderFunction{
def main(args :Array[String]){
val input = args(0).toInt
val intList :List[Int] //complete the code
def factorial //complete the code
def myHigherOrderFunction //complete the code
myHigherOrderFunction(factorial, intList)
}
}`