diff options
| author | Tyge Løvset <[email protected]> | 2021-02-04 11:12:16 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-02-04 11:12:16 +0100 |
| commit | 6b96779e99edc8715b85f3ac45536752b27314a6 (patch) | |
| tree | 966160e573e0d3b656f74b856afc6402a9372342 | |
| parent | 82a25ecd89d64a2226f30cb15d6612e61a56f057 (diff) | |
| download | STC-modified-6b96779e99edc8715b85f3ac45536752b27314a6.tar.gz STC-modified-6b96779e99edc8715b85f3ac45536752b27314a6.zip | |
Some docs.
| -rw-r--r-- | docs/ccommon_api.md | 16 | ||||
| -rw-r--r-- | examples/cbits_prime.c | 6 |
2 files changed, 13 insertions, 9 deletions
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md index 9e1d1767..cb2e9226 100644 --- a/docs/ccommon_api.md +++ b/docs/ccommon_api.md @@ -24,12 +24,16 @@ c_foreach (i, cvec_x, vec) sum += *i.ref; ``` #### c_forrange -Declare an iterator and specify a range to iterate with a for loop. -- c_forrange (end) -- c_forrange (it, end) -- c_forrange (it, IterType, end) -- c_forrange (it, IterType, begin, end) -- c_forrange (it, IterType, begin, end, step) +Declare an iterator and specify a range to iterate with a for loop. Like python's ***range()*** function: +- c_forrange (stop) # for _ in range(stop): +- c_forrange (i, stop) // IterType=size_t # for i in range(stop): +- c_forrange (i, IterType, stop) # for i in range(stop): +- c_forrange (i, IterType, start, stop) # for i in range(start, stop): +- c_forrange (i, IterType, start, stop, step) # for i in range(start, stop, step): +``` +c_forrange (i, int, -3, 3) printf(" %d", i); +// -3 -2 -1 0 1 2 +``` #### c_withbuffer diff --git a/examples/cbits_prime.c b/examples/cbits_prime.c index 5c5d3969..e2e7877a 100644 --- a/examples/cbits_prime.c +++ b/examples/cbits_prime.c @@ -16,17 +16,17 @@ static inline cbits sieveOfEratosthenes(size_t n) }
}
return primes;
-}
+}
int main(void)
{
int n = 100000000;
printf("computing prime numbers up to %u\n", n);
-
+
cbits primes = sieveOfEratosthenes(n);
puts("done");
-
+
size_t np = cbits_count(primes);
printf("number of primes: %zu\n", np);
|
