You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The second example is stated as "computes all pair ..." however the pair (9, 1), among other valid pairs, is not withing the results. Although (1, 9) is listed, (1, 9) is different than (9, 1). Just remembering that pairs are tuples of size 2 and are ordered, as opposed to a 'pair' in natural language. I changed the code accordingly and tested prior to submission.
Here `n == 10` and `v == 10`. On the first iteration, `i == 0` and `j == 0` so `i + j != v` and therefore nothing is yielded. `j` gets incremented 9 more times before `i` gets incremented to `1`. Without the `if` guard, this would simply print the following:
Note that comprehensions are not restricted to lists. Every datatype that supports the operations `withFilter`, `map`, and `flatMap` (with the proper types) can be used in sequence comprehensions.
@@ -59,7 +59,7 @@ You can omit `yield` in a comprehension. In that case, comprehension will return
0 commit comments