diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2019-02-09 12:08:53 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2019-02-09 12:08:53 +0100 |
commit | 91aeefea53fefb38de73d0cf5a812c45d74ed778 (patch) | |
tree | 34560d56d7dc8d9c2f7eb4ef2207e3cb31589031 /macro.h | |
parent | Add some more scheme bindings. (diff) | |
download | calp-91aeefea53fefb38de73d0cf5a812c45d74ed778.tar.gz calp-91aeefea53fefb38de73d0cf5a812c45d74ed778.tar.xz |
Add iterator macros.
Diffstat (limited to 'macro.h')
-rw-r--r-- | macro.h | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -79,6 +79,21 @@ /* + * Iterator macros. + */ +#define FOR(T, var, set) for( \ + BEG_ ## T (var, set); \ + END_ ## T (var, set); \ + NXT_ ## T (var, set)) + +/* Example int implementation + * FOR(int, i, 10) { } */ + +#define BEG_int(i, set) int i = 0 +#define NXT_int(i, set) i++ +#define END_int(i, set) i < set + +/* * General functions that different container types may implement. * Actuall implementation and type signature is mostly left to * individual implementations. |