fixed minor issue in midterm
This commit is contained in:
		| @@ -24,6 +24,13 @@ def predicates[T](list: List[T])(preds: List[T => Boolean]): List[T] = { | ||||
|   }) | ||||
| } | ||||
|  | ||||
| /* | ||||
| // Better solution | ||||
| def predicates[T](list: List[T])(preds: List[T => Boolean]): List[T] = { | ||||
|   preds.foldLeft(list)((acc, fun) => acc.filter(fun)) | ||||
| } | ||||
| */ | ||||
|  | ||||
| def fixedPoint(f: Int => Int): Int => Int = { | ||||
|   @tailrec | ||||
|   def func(x: Int): Int = { | ||||
|   | ||||
| @@ -16,7 +16,7 @@ abstract class Text { | ||||
|   def tail: Text = { | ||||
|     this match { | ||||
|       case Chars(cs) => Chars(cs.tail) | ||||
|       case Concat(t1, t2) => if (t2.isEmpty) t1.tail else Concat(t1, t2.tail) | ||||
|       case Concat(t1, t2) => if (t1.isEmpty) t2.tail else Concat(t1.tail, t2) | ||||
|     } | ||||
|   } | ||||
|   def map(f: Char => Char): Text = { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user