diff --git a/README.md b/README.md index f02b235..8c6d574 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,4 @@ To reformat code, run the script: `bash reformat_all_code.sh` +Run this command before pushing any code changes. If formatting is not applied, builds will fail. diff --git a/chapter02/src/test/scala/sofp/unit/Exercises_2_1_7.scala b/chapter02/src/test/scala/sofp/unit/Exercises_2_1_7.scala new file mode 100644 index 0000000..92d3adb --- /dev/null +++ b/chapter02/src/test/scala/sofp/unit/Exercises_2_1_7.scala @@ -0,0 +1,22 @@ +package sofp.unit + +import com.eed3si9n.expecty.Expecty.expect +import munit.FunSuite + +class Exercises_2_1_7 extends FunSuite { + + test("exercise 2.1.7.1") { + + val allPairs = + (0 to 9).flatMap { i => + (0 to 9).map { j => + (i, j) + } + } + val filteredPairs = allPairs.filter { case (i, j) => i + 4 * j > i * j } + + expect(filteredPairs.take(4) == Seq((0, 1), (0, 2), (0, 3), (0, 4))) + expect(filteredPairs.length == 64) + } + +}