summaryrefslogtreecommitdiff
path: root/tnslc/utils
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-03-30 02:46:04 -0400
committerKyle Gunger <kgunger12@gmail.com>2024-03-30 02:46:04 -0400
commit59aabd4ed77ff3ede1df368ad134c56a6f8787c0 (patch)
tree0dc74f277fa35eb7ec9d72cc793da094b18b4686 /tnslc/utils
parenta282af0b8fd4102778d6d8781c29f1c0202e13ee (diff)
in_csv function
Diffstat (limited to 'tnslc/utils')
-rw-r--r--tnslc/utils/iterator.tnsl28
-rw-r--r--tnslc/utils/utils.tnsl1
2 files changed, 29 insertions, 0 deletions
diff --git a/tnslc/utils/iterator.tnsl b/tnslc/utils/iterator.tnsl
new file mode 100644
index 0000000..b38d71f
--- /dev/null
+++ b/tnslc/utils/iterator.tnsl
@@ -0,0 +1,28 @@
+struct Iterator {
+ ~Vector v,
+ int pos
+}
+
+/; method Iterator
+ /; init(~Vector v)
+ self.v = v
+ self.pos = 0
+ ;/
+
+ /; get [~void]
+ return self.v`.get(self.pos)
+ ;/
+
+ /; next
+ /; if (self.pos + 1 < self.v`.count)
+ self.pos++
+ ;/
+ ;/
+
+ /; prev
+ /; if (self.pos > 0)
+ self.pos--
+ ;/
+ ;/
+;/
+
diff --git a/tnslc/utils/utils.tnsl b/tnslc/utils/utils.tnsl
index aa7968a..fece1da 100644
--- a/tnslc/utils/utils.tnsl
+++ b/tnslc/utils/utils.tnsl
@@ -3,4 +3,5 @@
:import "vector.tnsl"
:import "file.tnsl"
:import "algo.tnsl"
+ :import "iterator.tnsl"
;/