summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-09-22 07:28:20 +0200
committerTyge Løvset <[email protected]>2022-09-22 07:28:20 +0200
commit43b5d0ec65ecf06bc28c4ba90bd75aaa16d4169b (patch)
tree00497ba77f0c47a0943cb52861fa2179e5c4052b /examples
parentc3cefd740a90378a53698df639d7889c6baffcb8 (diff)
downloadSTC-modified-43b5d0ec65ecf06bc28c4ba90bd75aaa16d4169b.tar.gz
STC-modified-43b5d0ec65ecf06bc28c4ba90bd75aaa16d4169b.zip
Renamed c_forfiltered() back to c_forfilter(), and iter member .count => .taken
Diffstat (limited to 'examples')
-rw-r--r--examples/forfiltered.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/examples/forfiltered.c b/examples/forfiltered.c
index 71327629..2bea9a0a 100644
--- a/examples/forfiltered.c
+++ b/examples/forfiltered.c
@@ -1,4 +1,6 @@
#include <stdio.h>
+#define i_implement
+#include <stc/cstr.h>
#include <stc/csview.h>
#define i_type IVec
@@ -15,14 +17,14 @@ void demo1(void)
c_forarray (int, v, {0, 1, 2, 3, 4, 5, 80, 6, 7, 80, 8, 9, 80, 10, 11, 12, 13})
IVec_push(&vec, *v);
- c_forfiltered (i, IVec, vec, *i.ref != 80)
+ c_forfilter (i, IVec, vec, *i.ref != 80)
printf(" %d", *i.ref);
puts("");
- c_forfiltered (i, IVec, vec, i.idx >= 3 // drop(3)
- && i.idx != 5
- && *i.ref != 7,
- i.count < 5) // take(5)
+ c_forfilter (i, IVec, vec, i.idx >= 3 // drop(3)
+ && i.idx != 5
+ && *i.ref != 7,
+ i.taken < 5) // take(5)
printf(" %d", *i.ref);
puts("");
}
@@ -73,8 +75,8 @@ void demo3(void)
c_fortoken (w, sentence, " ")
SVec_push(&words, *w.ref);
- c_forfiltered (w, SVec, words,
- csview_contains(*w.ref, c_sv("i")))
+ c_forfilter (w, SVec, words,
+ csview_contains(*w.ref, c_sv("i")))
SVec_push(&words_containing_i, *w.ref);
c_foreach (w, SVec, words_containing_i)
@@ -83,10 +85,24 @@ void demo3(void)
}
}
+void demo4(void)
+{
+ csview s = c_sv("ab123cReAghNGnΩoEp");
+ cstr out = cstr_null;
+ c_forfilter (i, csview, s, utf8_isupper(utf8_peek(i.ref, 0)))
+ cstr_push(&out, i.ref);
+ //cstr_append_sv(&out, i.it.u8.chr);
+
+ printf("%s", cstr_str(&out));
+}
+
int main(void)
{
demo1();
demo2();
demo3();
+ demo4();
}
+
+#include "../src/utf8code.c" \ No newline at end of file