# HG changeset patch # User Christian Urban # Date 1471736312 -3600 # Node ID 5322e1c46890eb608df254bee95048ee9014b628 # Parent 4b454a6d1814fa193bf08747492564fe5436ffa8 added diff -r 4b454a6d1814 -r 5322e1c46890 progs/rev.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/progs/rev.scala Sun Aug 21 00:38:32 2016 +0100 @@ -0,0 +1,8 @@ +def rev(r: Rexp) : Rexp = r match { + case ZERO => ZERO + case ONE => ONE + case CHAR(c) => CHAR(c) + case ALT(r1, r2) => ALT(rev(r1), rev(r2)) + case SEQ(r1, r2) => SEQ(rev(r2), rev(r1)) + case STAR(r) => STAR(rev(r)) +}