progs/scala/positions.scala
author Chengsong
Mon, 10 Jul 2023 01:33:45 +0100
changeset 660 eddc4eaba7c4
parent 245 b16702bb6242
permissions -rw-r--r--
addresses Gerog "N_r meaning and relation with backtracking?" comment
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
     1
import scala.annotation.tailrec
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
     2
import scala.language.implicitConversions
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
     3
import scala.language.reflectiveCalls 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
     4
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
abstract class Rexp 
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
case object ZERO extends Rexp 
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
case object ONE extends Rexp
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
     9
case class CHAR(c: Char) extends Rexp 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    10
case class ALT(r1: Rexp, r2: Rexp) extends Rexp 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    11
case class SEQ(r1: Rexp, r2: Rexp) extends Rexp 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    12
case class STAR(r: Rexp) extends Rexp 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    13
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    14
// some convenience for typing in regular expressions
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    15
def charlist2rexp(s : List[Char]): Rexp = s match {
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    16
  case Nil => ONE
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    17
  case c::Nil => CHAR(c)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    18
  case c::s => SEQ(CHAR(c), charlist2rexp(s))
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
}
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    20
implicit def string2rexp(s : String) : Rexp = charlist2rexp(s.toList)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    21
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    22
implicit def RexpOps(r: Rexp) = new {
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    23
  def | (s: Rexp) = ALT(r, s)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    24
  def % = STAR(r)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    25
  def ~ (s: Rexp) = SEQ(r, s)
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    26
}
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    27
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    28
implicit def stringOps(s: String) = new {
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    29
  def | (r: Rexp) = ALT(s, r)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    30
  def | (r: String) = ALT(s, r)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    31
  def % = STAR(s)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    32
  def ~ (r: Rexp) = SEQ(s, r)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    33
  def ~ (r: String) = SEQ(s, r)
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
}
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    35
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    36
// enumerates regular expressions until a certain depth
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    37
// using the characters in the string
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    38
def generate(n: Int, s: String) : Set[Rexp] = n match {
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    39
  case 0 => Set(ZERO, ONE) ++ s.toSet.map(CHAR)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    40
  case n => {
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    41
    val rs = generate(n - 1, s)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    42
    rs ++
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    43
    (for (r1 <- rs; r2 <- rs) yield ALT(r1, r2)) ++
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    44
    (for (r1 <- rs; r2 <- rs) yield SEQ(r1, r2)) ++
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    45
    (for (r <- rs) yield STAR(r))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    46
  }
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    47
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    48
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    49
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    50
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    51
abstract class Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    52
case object Empty extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    53
case class Chr(c: Char) extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    54
case class Sequ(v1: Val, v2: Val) extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    55
case class Left(v: Val) extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    56
case class Right(v: Val) extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    57
case class Stars(vs: List[Val]) extends Val
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    58
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    59
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    60
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    61
// extracts a string from value
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    62
def flatten(v: Val) : String = v match {
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    63
  case Empty => ""
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    64
  case Chr(c) => c.toString
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    65
  case Left(v) => flatten(v)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    66
  case Right(v) => flatten(v)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    67
  case Sequ(v1, v2) => flatten(v1) + flatten(v2)
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    68
  case Stars(vs) => vs.map(flatten).mkString
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    69
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    70
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    71
def flat_len(v: Val) : Int = flatten(v).length
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    72
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    73
// extracts a set of candidate values from a "non-starred" regular expression
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    74
def values(r: Rexp) : Set[Val] = r match {
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    75
  case ZERO => Set()
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    76
  case ONE => Set(Empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    77
  case CHAR(c) => Set(Chr(c))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    78
  case ALT(r1, r2) => values(r1).map(Left(_)) ++ values(r2).map(Right(_)) 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    79
  case SEQ(r1, r2) => for (v1 <- values(r1); v2 <- values(r2)) yield Sequ(v1, v2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    80
  case STAR(r) => values(r).map(v => Stars(List(v))) ++ Set(Stars(Nil))  
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    81
    // to do much more would cause the set to be infinite
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    82
}
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    83
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    84
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    85
def values_str(r: Rexp, s: String) : Set[Val] =
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    86
  values(r).filter(flatten(_) == s)   
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    87
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    88
val List(val1, val2) = values_str(("ab" | "a") ~ ("c" | "bc"), "abc").toList
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    89
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    90
// Position
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    91
type Pos = List[Int]
195
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    92
c2d36c3cf8ad run all posix tests
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
    93
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    94
def positions(v: Val) : Set[Pos] = v match {
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    95
  case Empty => Set(Nil)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    96
  case Chr(c) => Set(Nil)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    97
  case Left(v) => Set(Nil) ++ positions(v).map(0::_) 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    98
  case Right(v) => Set(Nil) ++ positions(v).map(1::_)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
    99
  case Sequ(v1, v2) => Set(Nil) ++ positions(v1).map(0::_) ++ positions(v2).map(1::_)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   100
  case Stars(vs) => Set(Nil) ++ vs.zipWithIndex.flatMap{ case (v, n) => positions(v).map(n::_) }
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   101
} 
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   103
val v1 = Sequ(Chr('a'), Chr('b'))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   104
val ps1 = positions(v1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   105
val ps1L = positions(Left(v1))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   106
val ps1R = positions(Right(v1))
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   108
val v3 = Stars(List(Left(Chr('x')), Right(Left(Chr('y')))))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   109
val v4 = Stars(List(Right(Right(Sequ(Chr('x'), Chr('y'))))))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   110
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   111
val ps3 = positions(v3)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   112
val ps4 = positions(v4)
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   114
def at(v: Val, ps: List[Int]) : Val = (v, ps) match {
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   115
  case (v, Nil) => v
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   116
  case (Left(v), 0::ps) => at(v, ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   117
  case (Right(v), 1::ps) => at(v, ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   118
  case (Sequ(v1, v2), 0::ps) => at(v1, ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   119
  case (Sequ(v1, v2), 1::ps) => at(v2, ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   120
  case (Stars(vs), n::ps) => at(vs(n), ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   121
} 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   122
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   123
ps1.map(at(v1, _))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   124
ps1L.map(at(Left(v1), _))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   125
ps1R.map(at(Right(v1), _))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   126
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   128
def pflat_len(v: Val, p: Pos) : Int =
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   129
  if (positions(v) contains p) flat_len(at(v, p)) else -1
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   130
  
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   131
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   132
// for lexicographic list-orderings
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   133
import scala.math.Ordering.Implicits._
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   134
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   135
def smaller_than(pss: Set[Pos], ps: Pos) : Set[Pos] = 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   136
  pss.filter(_ < ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   137
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   138
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   139
// order from the alternative posix paper
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   140
def ordr(v1: Val, p: List[Int], v2: Val) : Boolean = { 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   141
  pflat_len(v1, p) > pflat_len(v2, p) && 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   142
  smaller_than(positions(v1) | positions(v2), p).forall(q => pflat_len(v1, q) == pflat_len(v2, q))
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
}
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   145
//tests
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   146
val List(val1, val2) = values_str(("ab" | "a") ~ ("c" | "bc"), "abc").toList
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   147
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   148
positions(val1).map(p => (p, ordr(val1, p, val2))).filter{ case (_, b) => b == true }
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   149
positions(val1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   150
at(val1, List(0))
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   151
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   152
smaller_than(positions(val1), List(1, 0))
168
6b0a1976f89a added parser for regexes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   154
val List(val1, val2) = values_str("a" ~ (("ab" | "a") ~ ("c" | "bc")), "aabc").toList
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 197
diff changeset
   155
positions(val2).map(p => (p, ordr(val2, p, val1))).filter{ case (_, b) => b == true }