diff options
| author | Tyge Løvset <[email protected]> | 2022-09-22 18:39:17 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-09-22 18:39:17 +0200 |
| commit | 047044ba50d73d81ed6ed1c77324c9bf873876cb (patch) | |
| tree | 91ee2e0ec8a6941b170251b3295f6ba4ca7cb5f7 | |
| parent | 4c5f0ba23ba6294e144243555ed3c02a72259692 (diff) | |
| download | STC-modified-047044ba50d73d81ed6ed1c77324c9bf873876cb.tar.gz STC-modified-047044ba50d73d81ed6ed1c77324c9bf873876cb.zip | |
Renamed .idx => .index in c_forfilter() macro
| -rw-r--r-- | examples/forfilter.c | 17 | ||||
| -rw-r--r-- | examples/list.c | 8 |
2 files changed, 15 insertions, 10 deletions
diff --git a/examples/forfilter.c b/examples/forfilter.c index e588e315..c7d3fae0 100644 --- a/examples/forfilter.c +++ b/examples/forfilter.c @@ -19,12 +19,17 @@ void demo1(void) c_forfilter (i, IVec, vec, *i.ref != 80) printf(" %d", *i.ref); - puts(""); - c_forfilter (i, IVec, vec, i.idx >= 3 // drop(3) - && i.idx != 5 - && *i.ref != 7, - i.taken < 5) // take(5) + + #define flt_drop(i, n) (i.index >= (n)) + #define flt_remove(i, x) (*i.ref != (x)) + #define flt_take(i, n) (i.taken < (n)) + #define flt_even(i) ((*i.ref & 1) == 0) + + c_forfilter (i, IVec, vec, flt_drop(i, 3) + && flt_even(i) + && flt_remove(i, 80) + , flt_take(i, 5)) printf(" %d", *i.ref); puts(""); } @@ -93,7 +98,7 @@ void demo4(void) cstr_push(&out, i.ref); //cstr_append_sv(&out, i.it.u8.chr); - printf("%s", cstr_str(&out)); + printf("%s\n", cstr_str(&out)); } diff --git a/examples/list.c b/examples/list.c index 9ed9ec76..d5f3996c 100644 --- a/examples/list.c +++ b/examples/list.c @@ -25,15 +25,15 @@ int main() { sum += *i.ref; printf("sum %f\n\n", sum); - c_forloop (i, clist_fx, list, i.idx < 10) - printf("%8d: %10f\n", (int)i.idx, *i.ref); + c_forloop (i, clist_fx, list, i.index < 10) + printf("%8d: %10f\n", (int)i.index, *i.ref); puts("sort"); clist_fx_sort(&list); // mergesort O(n*log n) puts("sorted"); - c_forloop (i, clist_fx, list, i.idx < 10) - printf("%8d: %10f\n", (int)i.idx, *i.ref); + c_forloop (i, clist_fx, list, i.index < 10) + printf("%8d: %10f\n", (int)i.index, *i.ref); puts(""); clist_fx_clear(&list); |
