progs/lecture5.scala
changeset 242 e6b34f617915
parent 240 b8cdaf51ffef
child 247 50a3b874008a
--- a/progs/lecture5.scala	Fri Dec 07 08:54:34 2018 +0000
+++ b/progs/lecture5.scala	Fri Dec 07 12:17:27 2018 +0000
@@ -20,7 +20,7 @@
 def peop(n: BigInt): Boolean = peop(n + 1) 
 
 val a = "foo"
-val b = "foo"
+val b = "bar"
 
 if (a == b || peop(0)) println("true") else println("false")
 
@@ -47,15 +47,15 @@
 val primes = generatePrimes(Stream.from(2))
 
 // the first 10 primes
-primes.take(10).toList
+primes.take(10).par.toList
 
 time_needed(1, primes.filter(_ > 100).take(3000).toList)
-time_needed(1, primes.filter(_ > 100).take(3000).toList)
+time_needed(1, primes.filter(_ > 100).take(1000).toList)
 
 // a stream of successive numbers
-Stream.from(2)
 
-Stream.from(2).take(10)
+Stream.from(2).print
+Stream.from(2).take(10).force
 Stream.from(2).take(10).print
 Stream.from(10).take(10).print
 
@@ -224,23 +224,6 @@
 }
 
 
-implicit def ParserOps[I<% Seq[_], T](p: Parser[I, T]) = new {
-  def | (q : => Parser[I, T]) = new AltParser[I, T](p, q)
-  def ==>[S] (f: => T => S) = new FunParser[I, T, S](p, f)
-  def ~[S] (q : => Parser[I, S]) = new SeqParser[I, T, S](p, q)
-}
-
-implicit def StringOps(s: String) = new {
-  def | (q : => Parser[String, String]) = new AltParser[String, String](s, q)
-  def | (r: String) = new AltParser[String, String](s, r)
-  def ==>[S] (f: => String => S) = new FunParser[String, String, S](s, f)
-  def ~[S] (q : => Parser[String, S]) = 
-    new SeqParser[String, String, S](s, q)
-  def ~ (r: String) = 
-    new SeqParser[String, String, String](s, r)
-}
-
-
 // atomic parsers  
 case class CharParser(c: Char) extends Parser[String, Char] {
   def parse(sb: String) =