added link file
authorChristian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 11 Jan 2017 12:18:34 +0000
changeset 95 4fa7231fede7
parent 94 ae4708c851ee
child 98 8f03f0dc3065
added link file
LINKS
marking/re2a_test.scala
marking/re2b_test.scala
marking/re2c_test.scala
progs/lecture2.scala
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LINKS	Wed Jan 11 12:18:34 2017 +0000
@@ -0,0 +1,2 @@
+Source of exercises
+    http://exercism.io
\ No newline at end of file
--- a/marking/re2a_test.scala	Wed Dec 21 03:06:18 2016 +0000
+++ b/marking/re2a_test.scala	Wed Jan 11 12:18:34 2017 +0000
@@ -11,4 +11,4 @@
   assert(iterT(10, (x: String) => x ++ "a", "a") == "aaaaaaaaaaa") 
 }
 
-Await.result(f, 120 second)
+Await.result(f, 90 second)
--- a/marking/re2b_test.scala	Wed Dec 21 03:06:18 2016 +0000
+++ b/marking/re2b_test.scala	Wed Jan 11 12:18:34 2017 +0000
@@ -20,7 +20,7 @@
   case CHAR(d) => if (c == d) ONE else ZERO
   case ALT(r1, r2) => ALT(der_urban(c, r1), der_urban(c, r2))
   case SEQ(r1, r2) => 
-    if (nullable(r1)) ALT(SEQ(der_urban(c, r1), r2), der_urban(c, r2))
+    if (nullable_urban(r1)) ALT(SEQ(der_urban(c, r1), r2), der_urban(c, r2))
     else SEQ(der_urban(c, r1), r2)
   case STAR(r1) => SEQ(der_urban(c, r1), STAR(r1))
 }
@@ -41,10 +41,16 @@
   case r => r
 }
 
+import scala.annotation.tailrec
+
+@tailrec
+def iterT_urban[A](n: Int, f: A => A, x: A): A = 
+  if (n == 0) x else iterT_urban(n - 1, f, f(x)) 
+
 
 lazy val f = Future {
-  assert(size(iterT(20, (r: Rexp) => der_urban('a', r), EVIL_urban)) == 7340068) 
-  assert(size(iterT(20, (r: Rexp) => simp_urban(der_urban('a', r)), EVIL_urban)) == 8) 
+  assert(size(iterT_urban(20, (r: Rexp) => der_urban('a', r), EVIL_urban)) == 7340068) 
+  assert(size(iterT_urban(20, (r: Rexp) => simp_urban(der_urban('a', r)), EVIL_urban)) == 8) 
 }
 
-Await.result(f, 120 second)
+Await.result(f, 90 second)
--- a/marking/re2c_test.scala	Wed Dec 21 03:06:18 2016 +0000
+++ b/marking/re2c_test.scala	Wed Jan 11 12:18:34 2017 +0000
@@ -10,4 +10,4 @@
   assert(fixpT((x:Long) => if (20 < x) x else x + 1, 0L) == 21L)
 }
 
-Await.result(f, 120 second)
+Await.result(f, 90 second)
--- a/progs/lecture2.scala	Wed Dec 21 03:06:18 2016 +0000
+++ b/progs/lecture2.scala	Wed Jan 11 12:18:34 2017 +0000
@@ -348,6 +348,8 @@
 // a student showed me...
 import scala.collection.mutable.ListBuffer
 
+
+
 def collatz_max(bnd: Long): (Long, Long) = {
   val colNos = ListBuffer[(Long, Long)]()
   for (i <- (1L to bnd).toList) colNos += ((collatz(i), i))