From 93943539ab2c553d68677d273ca08b135006b09a Mon Sep 17 00:00:00 2001 From: dam Date: Mon, 27 Mar 2023 23:49:08 +0100 Subject: Added step iterator. --- unused.jai | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/unused.jai b/unused.jai index 04997c5..b995d0d 100644 --- a/unused.jai +++ b/unused.jai @@ -1,4 +1,32 @@ +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // + + +Step_Iterator :: struct { + min: int; + max: int; + step: int; +} + +step_iterator :: (min: int, max: int, step: int) -> Step_Iterator { + return .{ min, max, step }; +} +for_expansion :: (iterator: Step_Iterator, body: Code, flags: For_Flags) #expand { + iteration_count: int; + for <=cast(bool)(flags & .REVERSE) i: iterator.min..iterator.max { + iteration_count += 1; + if iteration_count % iterator.step == 0 continue; + + `it := i; + `it_index := void; + + #insert body; + } +} + +for step_iterator(0, 10, 2) { + log("%", it); +} // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // -- cgit v1.2.3