Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

one more solution #3

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
22 changes: 22 additions & 0 deletions chapter02/src/test/scala/sofp/unit/Exercises_2_1_7.scala
Original file line number Diff line number Diff line change
@@ -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)
}

}
Loading