Skip to content

Commit

Permalink
Add docs for ranges' .sum and .contains
Browse files Browse the repository at this point in the history
  • Loading branch information
hsutter committed Aug 23, 2024
1 parent 08a5ebb commit 065a993
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/cpp2/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ For more examples, see also the examples in the previous two sections on `is` an
For example:
``` cpp title="Using ..< and ..= for ranges" hl_lines="5 11"
``` cpp title="Using ..< and ..= for ranges" hl_lines="5 11 16-18"
test: (v: std::vector<std::string>) =
{
// Print strings from "Nonesuch" (if present) onward
Expand All @@ -266,6 +266,10 @@ test: (v: std::vector<std::string>) =
std::cout << " (e)$ (v[e])$\n";
}
}
std::cout << " ((1 ..= 100).sum())$ \n";
std::cout << " ((1 ..< 100).contains(99))$ \n";
std::cout << " ((1 ..< 100).contains(100))$ \n";
}
main: () = {
Expand All @@ -277,6 +281,9 @@ main: () = {
// Wumpus
// 1 Grue
// 2 Nonesuch
// 5050
// true
// false
```


Expand Down

0 comments on commit 065a993

Please sign in to comment.