Skip to content

Commit

Permalink
Merge pull request seanbaxter#9 from x432ph/patch-1
Browse files Browse the repository at this point in the history
Weird typo that confused me
  • Loading branch information
seanbaxter authored Jan 8, 2021
2 parents cf3df36 + 99df81c commit be23b6f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion comprehension/comprehension.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ std::vector<int> a { 5, 3, 1, 4, 2, 3, 5, 1 }, b { 2, 1, 4, 6, 2, 0, 9, 5 };
int sum = (... + a[:]);
int greater = (... + (int)(a[:] > b[:]));
bool has_equal = (... || (a[:]==b[:]));
int max = (... + std::max a[:]);
int max = (... std::max a[:]);
```

Circle also extends _fold-expressions_ to participate in dynamic pack expansion. We can provide a binary operator or two-parameter function and iteratively apply it to each element in the dynamic pack expression, reducing the results into the initializer object. `sum` simply adds up all the elements in a. `greater` compares each pair of elements, and increments the counter when the comparison is true. `has_equal` is set to true if any corresponding elements have the same value. `max` holds the largest value in `a`.
Expand Down

0 comments on commit be23b6f

Please sign in to comment.