0

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.

skaffman
  • 398,947
  • 96
  • 818
  • 769
aioobe
  • 413,195
  • 112
  • 811
  • 826
  • Please mention that you’re using 2.7… (We should have a tag for that one instead of the scala-2.8 tag nowadays.) – Debilski Nov 18 '10 at 20:02
  • Sorry about that... I didn't realize that the two versions are so different. – aioobe Nov 18 '10 at 20:04
  • Concerning collections they are. You maybe should install sbt to get scala 2.8 running easily. – Debilski Nov 18 '10 at 20:05
  • I've tried installing sbt and failed :-( When I run `sbt` I get `java.lang.NoClassDefFoundError: scala/ScalaObject`. You have a suggestion on what I should try, or should I post a separate question? – aioobe Nov 18 '10 at 20:11
  • Hmm. Sorry, I don’t have any quick help for that. Better you ask a new question. – Debilski Nov 18 '10 at 20:13
  • @Debilski You are absolutely right. As it happens, some of us can do that. – Daniel C. Sobral Nov 18 '10 at 23:31

2 Answers2

4

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.

Debilski
  • 66,976
  • 12
  • 110
  • 133
2

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)
mkneissl
  • 4,902
  • 2
  • 26
  • 28