summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/forloops.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-03-22 17:32:21 +0100
committerTyge Løvset <[email protected]>2023-03-22 17:32:21 +0100
commite6a25eaaf4687ff99d0d719d0b32ad512156039e (patch)
tree6bc1730f6882eb054c6472361487a0be8b85c7aa /misc/examples/forloops.c
parent66429475ed6ac0deaba85989174e8880762d7888 (diff)
downloadSTC-modified-e6a25eaaf4687ff99d0d719d0b32ad512156039e.tar.gz
STC-modified-e6a25eaaf4687ff99d0d719d0b32ad512156039e.zip
Added c_foreach_r() macro for reverse iter of cvec, cdeq, cstack.
Moved c_find_if, c_erase_if, c_eraseremove_if to algo/filter.h Internals.
Diffstat (limited to 'misc/examples/forloops.c')
-rw-r--r--misc/examples/forloops.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/misc/examples/forloops.c b/misc/examples/forloops.c
index 144ec637..2fe21c8b 100644
--- a/misc/examples/forloops.c
+++ b/misc/examples/forloops.c
@@ -35,11 +35,8 @@ int main()
printf(" %s", *i.ref);
puts("");
- 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 (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})
@@ -51,8 +48,12 @@ int main()
puts("\n\nc_foreach:");
c_foreach (i, IVec, vec)
printf(" %d", *i.ref);
- puts("");
+ puts("\n\nc_foreach_r: reverse");
+ c_foreach_r (i, IVec, vec)
+ printf(" %d", *i.ref);
+
+ puts("\n\nc_foreach in map:");
c_foreach (i, IMap, map)
printf(" (%d %d)", i.ref->first, i.ref->second);