summaryrefslogtreecommitdiff
path: root/lib/array.fnl
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2024-10-17 10:32:35 +0600
committerunwox <me@unwox.com>2024-10-17 10:53:30 +0600
commitff8c6c9dde3a877b51e2fabafa579e2c05dc856e (patch)
tree3b6c9d8638ee78f913540e25ac7fc17433b906b6 /lib/array.fnl
parent43c7b5de358e8a158e9ed3c396d3866845682515 (diff)
implement caching
Diffstat (limited to 'lib/array.fnl')
-rw-r--r--lib/array.fnl12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/array.fnl b/lib/array.fnl
index 8b81c5c..8af6244 100644
--- a/lib/array.fnl
+++ b/lib/array.fnl
@@ -53,6 +53,16 @@
(lua "return true")))
false)
+(fn list [obj]
+ (local result [])
+ (var cursor 1)
+ (each [_ v (pairs obj)]
+ (tset result cursor v)
+ (set cursor (+ 1 cursor)))
+ ;; sort so we always return the same list for the same object
+ (table.sort result)
+ result)
+
(local join table.concat)
-{: sort : concat : diff : unique : flatten : join : contains}
+{: sort : concat : diff : unique : flatten : join : contains : list}