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, 04.07.2019 18:10
A-mn has a cubic structure with a0 0.8931 nm and a density of 7.47 g/cm3. b-mn has a different cubic structure, with a0 0.6326 nm and a density of 7.26 g/cm3. the atomic weight of manganese is 54.938 g/mol and the atomic radius is 0.112 nm. determine the percent volume change that would occur if a-mn transforms to b-mn.
Answers: 2
question
Engineering, 04.07.2019 18:20
Air is compressed isentropically from an initial state of 300 k and 101 kpa to a final temperature of 1000 k. determine the final pressure using the following approaches: (a) approximate analysis (using properties at the average temperature) (b) exact analysis
Answers: 1
question
Engineering, 04.07.2019 19:10
What is creep? what is stress relaxation?
Answers: 1
question
Engineering, 04.07.2019 19:10
Afoot bridge is made as a simple deck, 4 m long, with a cross section 2 m (wide) and 20 cm thick, and made of wood. the deck is supported at the two ends. the maximum load allowable on the bridge is 10 tons, provided it is uniformly distributed on the deck. to sense this load, a strain gauge is placed at the center of the bridge and its resistance is monitored. if the sensor has a nominal resistance of 350 s2 and a gauge factor of 3.6, what is the reading of the strain gauge at maximum load? the modulus of elasticity for the wood used in the construction is 10 gpa.
Answers: 2
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
Mathematics, 05.05.2020 10:48
question
Health, 05.05.2020 10:48
question
Mathematics, 05.05.2020 10:48
question
Biology, 05.05.2020 10:48
question
Mathematics, 05.05.2020 10:48
question
Chemistry, 05.05.2020 10:48