Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Must be Written in Scala PLEASE Write a recursive procedure that returns true if the list has the Fibonacci property. Le, every element at position
Must be Written in Scala PLEASE
Write a recursive procedure that returns true if the list has the Fibonacci property. Le, every element at position i 2 2 is the sum of the two preceding elements Note that the property is trivially true for lists of sizes 0 and 1. def sFibonacciList (1st : NunList): Boolean : { YOUR CODE HERE val 11 = Cons(12, Cons(25, Cons(37, Nil))) assert(isFibonaccilist (11), Test case 1:isFibonaccilist (11)should return true" val 12Cons (14, Cons(-1, Cons(13, 11 ) assert (isFibonaccilist(12), "Test case 2 : stibonacciList (12) -- should return true" val 13 = Cons(7, Cons(7, 12)) assert(!isFibonaccilist(13), "Test case 3 : sFibonacciList(13) -- should return false") | val 14-Cons(0, Cons(0, Cons(0, Cons(0, Cons(0, Cons(0, Nil)))))) assert(isFibonaccilist(12), Test case 4: isFibonaccilist(14)should return true passed(7) Write a recursive procedure that returns true if the list has the Fibonacci property. Le, every element at position i 2 2 is the sum of the two preceding elements Note that the property is trivially true for lists of sizes 0 and 1. def sFibonacciList (1st : NunList): Boolean : { YOUR CODE HERE val 11 = Cons(12, Cons(25, Cons(37, Nil))) assert(isFibonaccilist (11), Test case 1:isFibonaccilist (11)should return true" val 12Cons (14, Cons(-1, Cons(13, 11 ) assert (isFibonaccilist(12), "Test case 2 : stibonacciList (12) -- should return true" val 13 = Cons(7, Cons(7, 12)) assert(!isFibonaccilist(13), "Test case 3 : sFibonacciList(13) -- should return false") | val 14-Cons(0, Cons(0, Cons(0, Cons(0, Cons(0, Cons(0, Nil)))))) assert(isFibonaccilist(12), Test case 4: isFibonaccilist(14)should return true passed(7)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started