progs/rev.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 07 Oct 2016 22:08:03 +0100
changeset 444 3056a4c071b0
parent 408 5322e1c46890
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
408
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
def rev(r: Rexp) : Rexp = r match {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
  case ZERO => ZERO
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
  case ONE => ONE
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
  case CHAR(c) => CHAR(c)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
  case ALT(r1, r2) => ALT(rev(r1), rev(r2))
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
  case SEQ(r1, r2) => SEQ(rev(r2), rev(r1))
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
  case STAR(r) => STAR(rev(r))
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
}