summaryrefslogtreecommitdiffhomepage
path: root/misc/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-04-03 12:43:50 +0200
committerTyge Løvset <[email protected]>2023-04-03 18:24:41 +0200
commita3dc31d5393d051ad4dacb314452d3c6ec8a74b7 (patch)
tree35c11eb9542ef448ab6a40642a17f7a4025df823 /misc/examples
parente88b655ca8cf28d357f5088c205857954ad269e2 (diff)
downloadSTC-modified-a3dc31d5393d051ad4dacb314452d3c6ec8a74b7.tar.gz
STC-modified-a3dc31d5393d051ad4dacb314452d3c6ec8a74b7.zip
Split priv/template.h in two files to make mksingle.sh work.
Diffstat (limited to 'misc/examples')
-rw-r--r--misc/examples/forfilter.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/misc/examples/forfilter.c b/misc/examples/forfilter.c
index 0d72bd1b..daea68b9 100644
--- a/misc/examples/forfilter.c
+++ b/misc/examples/forfilter.c
@@ -9,10 +9,6 @@
#define i_val int
#include <stc/cstack.h>
-#define i_type SVec
-#define i_valclass csview
-#include <stc/cstack.h>
-
// filters and transforms:
#define flt_skipValue(i, x) (*i.ref != (x))
#define flt_isEven(i) ((*i.ref & 1) == 0)
@@ -55,11 +51,9 @@ fn main() {
println!("{:?}", vector); // Print result
}
*/
-
void demo2(void)
{
IVec vector = {0};
-
c_forfilter (x, crange, crange_object(INT64_MAX),
c_flt_skipwhile(x, *x.ref != 11) &&
(*x.ref % 2) != 0 &&
@@ -67,11 +61,9 @@ void demo2(void)
){
IVec_push(&vector, (int)(*x.ref * *x.ref));
}
+ c_foreach (x, IVec, vector) printf(" %d", *x.ref);
- c_foreach (x, IVec, vector)
- printf(" %d", *x.ref);
puts("");
-
IVec_drop(&vector);
}
@@ -88,6 +80,10 @@ fn main() {
println!("{:?}", words_containing_i);
}
*/
+#define i_type SVec
+#define i_valclass csview
+#include <stc/cstack.h>
+
void demo3(void)
{
const char* sentence = "This is a sentence in C99.";
@@ -102,8 +98,8 @@ void demo3(void)
c_foreach (w, SVec, words_containing_i)
printf(" %.*s", c_SV(*w.ref));
- puts("");
+ puts("");
c_drop(SVec, &words, &words_containing_i);
}