From 3eedc22aa633e3d0b8ceb755f91a19364a6a6f7a Mon Sep 17 00:00:00 2001 From: "sergei.winitzki" Date: Wed, 29 Nov 2023 10:53:33 +0100 Subject: [PATCH] fix readme --- README.md | 6 +++++- chapter02/worksheets/solution2.1.7.3_AR.scala | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fb4d981..a8a79b6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,11 @@ Solutions for each chapter is a submodule in this project. Common code may be put into the `common` submodule. -Files under `worksheets/` may be arbitrary Scala code, not made into a test. SBT will ignore those files. +Files under `worksheets/` may be arbitrary Scala code, not made into a test. + +## Verifying worksheets + +Run the command `bash run_sbt.sh test` in order to verify all solutions. This will create temporary solution files in each chapter. # Code formatting diff --git a/chapter02/worksheets/solution2.1.7.3_AR.scala b/chapter02/worksheets/solution2.1.7.3_AR.scala index af565dd..84e9dae 100644 --- a/chapter02/worksheets/solution2.1.7.3_AR.scala +++ b/chapter02/worksheets/solution2.1.7.3_AR.scala @@ -5,7 +5,8 @@ Given two sequences p: Seq[String] and q: Seq[Boolean] of equal length, compute Seq[String] with those elements of p for which the corresponding element of q is true. Hint: use zip, map, filter. */ -Seq("Joe", "Bob", "Mary").zip(Seq(true, false, true)).map { case (x, y) => if (y == true) x }.filter(_ != (())).map{ case x => x.toString } +val result = Seq("Joe", "Bob", "Mary").zip(Seq(true, false, true)).map { case (x, y) => if (y == true) x }.filter(_ != (())).map{ case x => x.toString } +assert(result == List("Joe", "Mary")) // scala> :load solution2.1.7.3_AR.scala // Loading solution2.1.7.3_AR.scala...