문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top