diff options
| author | Tyge Lovset <[email protected]> | 2023-04-09 23:22:22 +0200 |
|---|---|---|
| committer | Tyge Lovset <[email protected]> | 2023-04-09 23:22:22 +0200 |
| commit | 680faa169dfc7e7d4fc7532922bf7103f8cdc279 (patch) | |
| tree | c37dcdb87850c9a008cfe6ddd7d0282a531b1279 /docs | |
| parent | d717656f4728d3cbbc9ade1c314275334c62466d (diff) | |
| download | STC-modified-680faa169dfc7e7d4fc7532922bf7103f8cdc279.tar.gz STC-modified-680faa169dfc7e7d4fc7532922bf7103f8cdc279.zip | |
Added some online examples.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ccommon_api.md | 7 | ||||
| -rw-r--r-- | docs/csmap_api.md | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md index 6015b959..7a3c3196 100644 --- a/docs/ccommon_api.md +++ b/docs/ccommon_api.md @@ -125,8 +125,9 @@ Iterate a container/range with chained range filtering. | `c_flt_takewhile(it, predicate)` | Take items until predicate is false | | `c_flt_counter(it)` | Increment current and return count | | `c_flt_getcount(it)` | Number of items passed skip*/take*/counter | + +[ [Run this example](https://godbolt.org/z/n9aYrYPv8) ] ```c -// Example: #include <stc/calgo.h> #include <stdio.h> @@ -135,6 +136,7 @@ bool isPrime(long long i) { if (i % j == 0) return false; return true; } + int main() { // Get 10 prime numbers starting from 1000. Skip the first 15 primes, // then select every 25th prime (including the initial). @@ -148,7 +150,6 @@ int main() { ){ printf(" %lld", *i.ref); } - puts(""); } // out: 1097 1289 1481 1637 1861 2039 2243 2417 2657 2803 ``` @@ -290,6 +291,8 @@ coroutine. It can also store input and output data if desired. The coroutine example below generates Pythagorian triples, but the calling loop skips the triples which are upscaled version of smaller ones, by checking the gcd() function. It also ensures that it stops when the diagonal size >= 100: + +[ [Run this code](https://godbolt.org/z/coqqrfbd5) ] ```c #include <stc/calgo.h> diff --git a/docs/csmap_api.md b/docs/csmap_api.md index 59914369..4a5e911f 100644 --- a/docs/csmap_api.md +++ b/docs/csmap_api.md @@ -146,7 +146,9 @@ The HEX of color BLACK is:[#000000] ### Example 2 Translate a [C++ example using *insert* and *emplace*](https://en.cppreference.com/w/cpp/container/map/try_emplace) - to STC: [ [Run this code](https://godbolt.org/z/9d1PP77Pa) ] + to STC: + +[ [Run this code](https://godbolt.org/z/9d1PP77Pa) ] ```c #include <stc/cstr.h> #define i_type strmap |
