aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2023-03-27 23:49:08 +0100
committerdam <dam@gudinoff>2023-03-27 23:49:08 +0100
commit93943539ab2c553d68677d273ca08b135006b09a (patch)
tree517d43adf5e2d6a7b555495a962f8fd2c8c01e3b
parente4bae939aea065fa5745e224fc0eb12d5136d1c4 (diff)
downloadtask-time-tracker-93943539ab2c553d68677d273ca08b135006b09a.tar.zst
task-time-tracker-93943539ab2c553d68677d273ca08b135006b09a.zip
Added step iterator.
-rw-r--r--unused.jai28
1 files changed, 28 insertions, 0 deletions
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);
+}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- //