Skip to content

Commit

Permalink
fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei.winitzki committed Nov 29, 2023
1 parent ee9d26c commit 3eedc22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion chapter02/worksheets/solution2.1.7.3_AR.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down

0 comments on commit 3eedc22

Please sign in to comment.