Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Scala Programming Who let the dogs out, really? You are given text as an input string which talks about people letting dogs out. We would

Scala Programming

Who let the dogs out, really?

You are given text as an input string which talks about people letting dogs out. We would like to extract the list of all the strings that let the dogs out.

In other words, we look for all substrings of the form ..... let the dogs out and return all the words that occur immediately before the phrase "let the dogs out" in the input string.

Example

" The society let the dogs out Letting the dogs out is the very essence of our democracy I let the dogs out You let the dogs out My grandma let the dogs out Your dad let the dogs out We all let the dogs out The dogs let themselves out"

Your function should return the list List("society", "I", "You", "grandma', "dad", "all").

Use the functions that you have implemented so far in your solution.

  • Use splitIntoWords to convert it into a list of words.
  • Use findPatternIndicesInList to search for all indices where the pattern List("let", "the", "dogs", "out") appears.
  • Subtract 1 from all the indices that are > 0 to extract the result.

In [ ]:

 
def whoLetTheDogsOut(txt: String): List[String] = {
 // YOUR CODE HERE
 ???
}

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_2

Step: 3

blur-text-image_3

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

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago

Question

What was the role of the team leader? How was he or she selected?

Answered: 1 week ago

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago