summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/forloops.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-03-12 13:30:15 +0100
committerTyge Løvset <[email protected]>2023-03-12 13:30:15 +0100
commitc9be5f66a481bd040b36a25314f6589dd939daa5 (patch)
treed71cc01f17fabc526a72219c225b015b4130c8b3 /misc/examples/forloops.c
parent1ac8bb4ff664baa838b44ed6bf62225766f000c5 (diff)
downloadSTC-modified-c9be5f66a481bd040b36a25314f6589dd939daa5.tar.gz
STC-modified-c9be5f66a481bd040b36a25314f6589dd939daa5.zip
Safer state machine in coroutine.h (internal).
Removed c_forwhile() macro. Redundant, use c_forfilter(). Removed find and eq in cspan (use general c_find_if() instead for search).
Diffstat (limited to 'misc/examples/forloops.c')
-rw-r--r--misc/examples/forloops.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/misc/examples/forloops.c b/misc/examples/forloops.c
index 707e8285..144ec637 100644
--- a/misc/examples/forloops.c
+++ b/misc/examples/forloops.c
@@ -60,20 +60,20 @@ int main()
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)
+ puts("\n\nc_forfilter 1:");
+ c_forfilter (i, IVec, vec, c_flt_take(i, 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))
- && isOdd(i)
- && c_flt_skip(i, 2)
- && c_flt_take(i, 2))
+ puts("\n\nc_forfilter 2:");
+ 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, 2))
printf(" %d", *i.ref);
puts("");
// 189