summaryrefslogtreecommitdiff
path: root/dot_config/nvim/fnl/toast/table.fnl
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config/nvim/fnl/toast/table.fnl')
-rw-r--r--dot_config/nvim/fnl/toast/table.fnl15
1 files changed, 15 insertions, 0 deletions
diff --git a/dot_config/nvim/fnl/toast/table.fnl b/dot_config/nvim/fnl/toast/table.fnl
new file mode 100644
index 0000000..a294b14
--- /dev/null
+++ b/dot_config/nvim/fnl/toast/table.fnl
@@ -0,0 +1,15 @@
+(fn from-pairs [t ?mut]
+ "Convert a list of [k v] pairs to a table.
+ If an initial table ?mut is provided, it will be mutated and returned."
+ (let [out (or ?mut {})]
+ (each [_ [k v] (ipairs t)]
+ (tset out k v))
+ out))
+
+(fn insert [t ...]
+ "Like table.insert, but returns the mutated table."
+ (table.insert t ...)
+ t)
+
+{: from-pairs
+ : insert}