Question

Sitting with the following error:

TestCaseGenerator.scala:47: error: type mismatch;
 found   : List[(State, Seq.Projection[State])]
 required: Seq[(State, Set[State])]
    new LTS(Map(rndTrans: _*), Map(rndLabeling: _*))
                ^
one error found

Can't figure out what to do about it.

The rndTrans is initialized as follows:

val rndTrans = for (s <- (0 to nStates).toList)
                   yield (new State(s) -> (for (s2 <- 0 to nStates
                       if prob(trans_probability))
                           yield new State(s2)))

Update: I happen to be using version 2.7.

Was it helpful?

Solution

When a toSet method (or toMap) is not available (because one is running an older version of scala or because the conversion is just not implemented), one can often apply one of the following schemes.

val collection: Seq[SomeType] = ...

Set( collection: _* )

or

Set() ++ collection

The first version uses the :_* to convert the collection to a sequence argument and then calls a constructor method of the new collection type. The second method created an empty collection of the new type and then adds (++) the old collection to it.

OTHER TIPS

Generally a Seq is not a Set. Try converting the value sequence to a set.

val rndTrans = for (s <- (0 to nStates).toList)
                   yield (new State(s) -> (for (s2 <- 0 to nStates
                       if prob(trans_probability))
                           yield new State(s2)).toSet)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top