progs/app7.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Sun, 10 Sep 2023 12:24:55 +0100
changeset 917 89e05a230d2d
parent 295 19f23c4c2167
permissions -rw-r--r--
updated
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] =
295
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
     5
    for ((head, tail) <- parse(ts); 
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
     6
         if (tail.isEmpty)) yield head
66
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