snerd
snerd

Reputation: 1297

scala challenge - what am I missing?

Working through the 99 scala problems and confused by problem 23. To my eyes, the example is incongruent with the stated problem. Specifically the Symbol 'e in the resulting list isn't in among the input. Am I missing something?

Problem and example are as follows:

P23 (**) Extract a given number of randomly selected elements from a list.
    Example:

    scala> randomSelect(3, List('a, 'b, 'c, 'd, 'f, 'g, 'h))
    res0: List[Symbol] = List('e, 'd, 'a)

    Hint: Use the solution to problem P20

Upvotes: 1

Views: 167

Answers (1)

Ben Reich
Ben Reich

Reputation: 16324

That's just a typo. I looked at the solution and it would never add an extra letter.

Furthermore, these Scala problems are an adaptation of these Ninety-Nine Prolog Problems. You can see the equivalent question there, and note the e in the example:

P23 (**) Extract a given number of randomly selected elements from a list.
    The selected items shall be put into a result list.

Example:
    ?- rnd_select([a,b,c,d,e,f,g,h],3,L).
    L = [e,d,a]

You could contact the author via the feedback link on the page, if you are so inclined.

Upvotes: 2

Related Questions