summaryrefslogtreecommitdiff
path: root/generate.lua
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-11-07 23:02:15 +0100
committerAki <please@ignore.pl>2024-11-07 23:04:34 +0100
commita2ebf3467acc703a883403c95eeea28da06c3ca1 (patch)
tree48c68de3c78f75be83cdd0a54ae7321e13b99390 /generate.lua
parentd4dd6baae7ec7d4c02d978762cf4dd99b83ec04a (diff)
downloadnoita-eyes-a2ebf3467acc703a883403c95eeea28da06c3ca1.zip
noita-eyes-a2ebf3467acc703a883403c95eeea28da06c3ca1.tar.gz
noita-eyes-a2ebf3467acc703a883403c95eeea28da06c3ca1.tar.bz2
Calculate minimum distances to meaningful nodes in transformation graph
Diffstat (limited to 'generate.lua')
-rw-r--r--generate.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/generate.lua b/generate.lua
new file mode 100644
index 0000000..f046356
--- /dev/null
+++ b/generate.lua
@@ -0,0 +1,33 @@
+local function next_number (last, current)
+ current = current + 1
+ if current > last then
+ return nil
+ end
+ return current
+end
+
+
+local function range (first, last)
+ if first > last then
+ error "start of range must be less or equal to last value"
+ end
+ return next_number, last, first - 1
+end
+
+
+local generate = {
+ next_number = next_number,
+ range = range,
+}
+
+
+function generate.trange (first, last)
+ local x = {}
+ for i in range(first, last) do
+ table.insert(x, i)
+ end
+ return x
+end
+
+
+return generate