summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/forloops.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-02-08 16:16:49 +0100
committerTyge Løvset <[email protected]>2023-02-08 17:18:24 +0100
commitc4441f5fc665194fbd7a894a67a64a08c3beac42 (patch)
tree82f231b6e8fcb75625166f98aa785baaa265a3d6 /misc/examples/forloops.c
parent673dd5319a488d4b702b94dd9aeda4e497ae4fbc (diff)
downloadSTC-modified-c4441f5fc665194fbd7a894a67a64a08c3beac42.tar.gz
STC-modified-c4441f5fc665194fbd7a894a67a64a08c3beac42.zip
Changed to use lowercase flow-control macros in examples (uppercase will still be supported). Improved many examples to use c_make() to init containers.
Diffstat (limited to 'misc/examples/forloops.c')
-rw-r--r--misc/examples/forloops.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/misc/examples/forloops.c b/misc/examples/forloops.c
index cd3c4d9e..66c587c4 100644
--- a/misc/examples/forloops.c
+++ b/misc/examples/forloops.c
@@ -13,61 +13,61 @@
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_forfilter (i, IVec, vec
, c_flt_skipwhile(i, *i.ref != 65)
&& c_flt_takewhile(i, *i.ref != 280)
&& c_flt_skipwhile(i, isOdd(i))