Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***Utilizing Scala*** Please show screenshot of output /*You MUST NOT use while loops or (re)assignment to variables (you can use val declarations, * but not

***Utilizing Scala***

Please show screenshot of output

/*You MUST NOT use while loops or (re)assignment to variables (you can use "val" declarations, * but not "var" declarations). You must use recursion instead. * * You may declare auxiliary functions if you like. * */

concat_list.sc: // Write a function "concatList" that takes a list of strings and concatenates them with a comma between them. Your function should return the empty string for the empty list. Your function should return the string when called with a singleton list (list with one element). For longer lists, e.g., concatList ("a", "b", c") == "a,b,c". Your function MUST be recursive and MUST NOT use a while loop.

def concatList (xs : List[String]) : String = {

// TODO: Provide definition here. null }

concat_list.test.scala:

import scala.concurrent.Future

import scala.concurrent.duration.Duration

class Tests_concat_list extends munit.FunSuite {

implicit val ec : scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global

override val munitTimeout = Duration (1, "s")

import concat_list._

test ("concat_list") {

Future {

assert (concatList (Nil) == "")

assert (concatList (List ("abc")) == "abc")

assert (concatList (List ("abc", "d")) == "abc,d")

assert (concatList (List ("abc", "d", "ef")) == "abc,d,ef")

}

}

}

Please show screenshot of output

Thank you!

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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

Conduct an effective performance feedback session. page 360

Answered: 1 week ago