Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Write a function called removeAlternating that takes a List String] and produces a List[Stringl that has every other element in the input list. The

image text in transcribedimage text in transcribed

4. Write a function called removeAlternating that takes a List String] and produces a List[Stringl that has every other element in the input list. The first element of the input list must be in the output list. For example: Write a function called isDescending that takes a List[Int] and produces a Boolean that is true if the numbers in the input list are in descending order. Note that the input may have repeated numbers 5. 6. Write a function called addSub that consumes a List[Int] and produces an Int. The function should add all the elements in odd position and subtract all the elements in even position. Note that the indexes of the first element of a list is 0 so it is in even position. For example, addSub(List(10, 20, 30, 40)) should be -10 20 30+40 7. Write a function called alternate that takes two List[Int] arguments and produces a List[Int]. The elements of the resulting list should alternate between the elements of the arguments. Assume that the two arguments have the same length. For example: alternate (List (1,3,5), List (2,4, 6)) List (1,2, 3, 4, 5, 6) Write a function called fromTo that takes two Ints as arguments and produces a List[Int]. The value of fromTo(x, y) should be the list of consecutive integers that start from and include x going up to and excluding y. Assume that x

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

What is goodwill?

Answered: 1 week ago

Question

(1 point) Calculate 3 sin x cos x dx.

Answered: 1 week ago