progs/app7.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 29 Nov 2013 09:01:08 +0000
changeset 211 deece8c6cf3a
parent 169 57df3d7b4a25
child 295 19f23c4c2167
permissions -rw-r--r--
added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
66
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 7
diff changeset
     1
abstract class Parser[I, T] {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 7
diff changeset
     2
  def parse(ts: I): Set[(T, I)]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 7
diff changeset
     3
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 7
diff changeset
     4
  def parse_all(ts: I) : Set[T] =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 7
diff changeset
     5
    for ((head, tail) <- parse(ts); if (tail.isEmpty)) 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 7
diff changeset
     6
      yield head
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 7
diff changeset
     7
}
7
73cf4406b773 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
73cf4406b773 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9