Utils.scala 686 Bytes
Newer Older
Christian Müller's avatar
Christian Müller committed
1 2
package de.tum.workflows

3
import de.tum.workflows.blocks._
Christian Müller's avatar
Christian Müller committed
4 5
import de.tum.workflows.foltl.FOLTL._

Christian Müller's avatar
Christian Müller committed
6 7 8 9 10
object Utils {
  
  def mkString[T](string: Iterable[T], start: String, mid: String, end:String) = {
    if (string.isEmpty) "" else string.mkString(start, mid, end)
  }
Christian Müller's avatar
Christian Müller committed
11
  
12
   def collectChoices(w: Block): List[Fun] = {
Christian Müller's avatar
Christian Müller committed
13 14 15 16
     w match {
       case Loop(steps) => steps.flatMap(collectChoices _)
       case ForallMayBlock(agents, pred, _) => List(Fun(pred, agents))
       case b:ForallBlock => List()
17
       case NondetChoice(l,r) => l.flatMap(collectChoices) ++ r.flatMap(collectChoices)
Christian Müller's avatar
Christian Müller committed
18 19 20
     }
   }
  
21 22
  def allchoices(w: Workflow) = {
    w.steps flatMap (collectChoices _) toSet
Christian Müller's avatar
Christian Müller committed
23
  }
Christian Müller's avatar
Christian Müller committed
24
}