progs/re1.scala
changeset 479 52aa298211f6
parent 477 b78664a24f5d
child 481 acd8780bfc8b
--- a/progs/re1.scala	Wed Mar 15 14:34:10 2017 +0000
+++ b/progs/re1.scala	Fri Mar 17 12:15:58 2017 +0000
@@ -115,3 +115,23 @@
 size(EVIL1(3))  // 17
 size(EVIL1(5))  // 29
 size(EVIL1(7))  // 41
+
+
+// given a regular expression and building successive
+// derivatives might result into bigger and bigger
+// regular expressions...here is an example for this:
+
+val BIG_aux = STAR(ALT(CHAR('a'), CHAR('b')))
+val BIG = SEQ(BIG_aux, SEQ(CHAR('a'),SEQ(CHAR('b'), BIG_aux)))
+
+size(ders("".toList, BIG))              // 13
+size(ders("ab".toList, BIG))            // 51
+size(ders("abab".toList, BIG))          // 112
+size(ders("ababab".toList, BIG))        // 191
+size(ders("abababab".toList, BIG))      // 288
+size(ders("ababababab".toList, BIG))    // 403
+size(ders("abababababab".toList, BIG))  // 536
+
+
+size(ders(("ab" * 200).toList, BIG))    // 366808
+