subject
Engineering, 26.02.2020 01:48 Destinationz

We defined lists in the class. Write a recursive procedure to get the nth element of the list or throw an IllegalArgumentException if n <0 or n >= length of list. Assume n = 0 obtains the very first element and n = length of list - 1 yields very last element. 1 sealed trait NumList case object Nil extends NumList case class Cons(n: Int, l: NumList) extends NumList def getNthElement(lst: NumList, n: Int): Int = { ??? // YOUR CODE HERE B (7 points) Write a recursive procedure that returns true if the list has the Fibonacci property. I. e, every element at position i > 2 is the sum of the two preceding elements. Note that the property is trivially true for lists of sizes 0 and 1. 1 def isFibonacciList (lst: NumList): Boolean = { ??? // YOUR CODE HERE 3 } C (8 points) Write a recursive function filterNumList(l: NumList, f: Int => Boolean): NumList that takes in a NumList and a function f: Int => Boolean. 1. It should return a new list that consist of all elements of the list i that return true when the function f is called on them. 2. The returned list elements must preserve the same order as in the original list. 1 ??? // YOUR CODE HERE

ansver
Answers: 3

Another question on Engineering

question
Engineering, 03.07.2019 15:10
Two flowing streams of argon gas are adiabatically mixed to form a single flow/stream. one stream is 1.5 kg/s at 400 kpa and 200 c while the second stream is 2kg/s at 500 kpa and 100 ? . it is stated that the exit state of the mixed single flow of argon gas is 150 c and 300 kpa. assuming there is no work output or input during the mixing process, does this process violate either the first or the second law or both? explain and state all your assumptions.
Answers: 1
question
Engineering, 04.07.2019 18:10
Which from the following instrument is commonly used to detect the high pitch butzing sound in bearings? [clo4] a)-digital ultrasonic meter b)-infrared camera c)-spectroscopic d)-vibrometer
Answers: 2
question
Engineering, 04.07.2019 18:20
Describe one experiment in which the glass transition temperature and melting temperature of a totally amorphous thermoplastic material can be determined. show the relevant experimental results in a diagram which should be properly annotated with the two temperatures clearly marked. what is likely to happen to the curve in the diagram if the amorphous polymer is replaced by a thermosetting type?
Answers: 2
question
Engineering, 06.07.2019 03:10
Asolid steel sphere (k=63.9 w m-1 k-1 , ? =7832 kg m-3 , c=0.523 kj kg-1 k-1 ), 100 mm in diameter is initially at a uniform temperature of 500o c and is suddenly quenched in a large oil bath for which t? = 100o c and h = 3200 w m-2 k-1. estimate the time required for the sphere to cool to 200o c and to 110o c
Answers: 1
You know the right answer?
We defined lists in the class. Write a recursive procedure to get the nth element of the list or thr...
Questions
question
Spanish, 24.01.2021 01:10
question
Mathematics, 24.01.2021 01:10
question
Mathematics, 24.01.2021 01:10
question
Mathematics, 24.01.2021 01:20
question
Mathematics, 24.01.2021 01:20
question
Engineering, 24.01.2021 01:20
question
Computers and Technology, 24.01.2021 01:20
Questions on the website: 13722363