summaryrefslogtreecommitdiffhomepage
path: root/docs/ccommon_api.md
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2023-04-09 23:22:22 +0200
committerTyge Lovset <[email protected]>2023-04-09 23:22:22 +0200
commit680faa169dfc7e7d4fc7532922bf7103f8cdc279 (patch)
treec37dcdb87850c9a008cfe6ddd7d0282a531b1279 /docs/ccommon_api.md
parentd717656f4728d3cbbc9ade1c314275334c62466d (diff)
downloadSTC-modified-680faa169dfc7e7d4fc7532922bf7103f8cdc279.tar.gz
STC-modified-680faa169dfc7e7d4fc7532922bf7103f8cdc279.zip
Added some online examples.
Diffstat (limited to 'docs/ccommon_api.md')
-rw-r--r--docs/ccommon_api.md7
1 files changed, 5 insertions, 2 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>