summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/forloops.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-23 23:55:10 +0100
committerTyge Løvset <[email protected]>2022-12-23 23:55:10 +0100
commitd623c6c85071b9af5d607bb5d9aceceaea05220a (patch)
treef20fc3714f86e1553d1103bed6dc8efefcbd9d6b /misc/examples/forloops.c
parent5f57d597cd27aef55adbcb3b452973b0c6e33667 (diff)
downloadSTC-modified-d623c6c85071b9af5d607bb5d9aceceaea05220a.tar.gz
STC-modified-d623c6c85071b9af5d607bb5d9aceceaea05220a.zip
Experimental uppercase macros.
Diffstat (limited to 'misc/examples/forloops.c')
-rw-r--r--misc/examples/forloops.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/misc/examples/forloops.c b/misc/examples/forloops.c
index 2654f095..95a955a3 100644
--- a/misc/examples/forloops.c
+++ b/misc/examples/forloops.c
@@ -13,67 +13,67 @@
int main()
{
- puts("c_forrange:");
- c_forrange (30) printf(" xx");
+ puts("c_FORRANGE:");
+ c_FORRANGE (30) printf(" xx");
puts("");
- c_forrange (i, 30) printf(" %lld", i);
+ c_FORRANGE (i, 30) printf(" %lld", i);
puts("");
- c_forrange (i, 30, 60) printf(" %lld", i);
+ c_FORRANGE (i, 30, 60) printf(" %lld", i);
puts("");
- c_forrange (i, 30, 90, 2) printf(" %lld", i);
+ c_FORRANGE (i, 30, 90, 2) printf(" %lld", i);
puts("\n\nc_forlist:");
- c_forlist (i, int, {12, 23, 453, 65, 676})
+ c_FORLIST (i, int, {12, 23, 453, 65, 676})
printf(" %d", *i.ref);
puts("");
- c_forlist (i, const char*, {"12", "23", "453", "65", "676"})
+ c_FORLIST (i, const char*, {"12", "23", "453", "65", "676"})
printf(" %s", *i.ref);
puts("");
- c_forlist (i, const char*, {"12", "23", "453", "65", "676"})
+ c_FORLIST (i, const char*, {"12", "23", "453", "65", "676"})
printf(" %s", i.data[i.size - 1 - i.index]);
- c_auto (IVec, vec)
- c_auto (IMap, map)
+ c_AUTO (IVec, vec)
+ c_AUTO (IMap, map)
{
- c_forlist (i, int, {12, 23, 453, 65, 113, 215, 676, 34, 67, 20, 27, 66, 189, 45, 280, 199})
+ c_FORLIST (i, int, {12, 23, 453, 65, 113, 215, 676, 34, 67, 20, 27, 66, 189, 45, 280, 199})
IVec_push(&vec, *i.ref);
- c_forlist (i, IMap_value, {{12, 23}, {453, 65}, {676, 123}, {34, 67}})
+ c_FORLIST (i, IMap_value, {{12, 23}, {453, 65}, {676, 123}, {34, 67}})
IMap_push(&map, *i.ref);
puts("\n\nc_foreach:");
- c_foreach (i, IVec, vec)
+ c_FOREACH (i, IVec, vec)
printf(" %d", *i.ref);
puts("");
- c_foreach (i, IMap, map)
+ c_FOREACH (i, IMap, map)
printf(" (%d %d)", i.ref->first, i.ref->second);
puts("\n\nc_forpair:");
- c_forpair (key, val, IMap, map)
+ c_FORPAIR (key, val, IMap, map)
printf(" (%d %d)", *_.key, *_.val);
puts("\n\nc_forwhile:");
- c_forwhile (i, IVec, IVec_begin(&vec), i.index < 3)
+ c_FORWHILE (i, IVec, IVec_begin(&vec), i.index < 3)
printf(" %d", *i.ref);
#define isOdd(i) (*i.ref & 1)
puts("\n\nc_forfilter:");
- c_forfilter (i, IVec, vec
- , c_flt_skipwhile(i, *i.ref != 65)
- && c_flt_takewhile(i, *i.ref != 280)
- && c_flt_skipwhile(i, isOdd(i))
+ c_FORFILTER (i, IVec, vec
+ , c_FLT_SKIPWHILE(i, *i.ref != 65)
+ && c_FLT_TAKEWHILE(i, *i.ref != 280)
+ && c_FLT_SKIPWHILE(i, isOdd(i))
&& isOdd(i)
- && c_flt_skip(i, 2)
- , c_flt_take(i, 1))
+ && c_FLT_SKIP(i, 2)
+ , c_FLT_TAKE(i, 1))
printf(" %d", *i.ref);
puts("");
// 189