summaryrefslogtreecommitdiff
path: root/dot_config/nvim/fnl/toast/table.fnl
diff options
context:
space:
mode:
authorChloƩ Vulquin <code@toast.bunkerlabs.net>2024-08-07 21:51:15 +0200
committerChloƩ Vulquin <code@toast.bunkerlabs.net>2024-08-07 21:51:15 +0200
commit23d6644dbe76e22d8558657bfede7b5d471d6383 (patch)
tree6ef0b96be5a3e840548d125a208bca4d262d8827 /dot_config/nvim/fnl/toast/table.fnl
parentnvim: move mini plugin into a single file (diff)
nvim: rework mixed-table macro
I didn't like that you couldn't keep mixing and matching, so I made it so you can. In the process, I also implemented even?, odd?, filter, mapcat, flat, and concat. Some of them didn't end up needing to exist, and the entire :toast. namespace does need to be cleaned up. Then again, it's not like I'm selling this like an alternative stdlib. I should really try and port all of clojure.core though, it'd be funny.
Diffstat (limited to 'dot_config/nvim/fnl/toast/table.fnl')
-rw-r--r--dot_config/nvim/fnl/toast/table.fnl12
1 files changed, 11 insertions, 1 deletions
diff --git a/dot_config/nvim/fnl/toast/table.fnl b/dot_config/nvim/fnl/toast/table.fnl
index fe118e8..17934b2 100644
--- a/dot_config/nvim/fnl/toast/table.fnl
+++ b/dot_config/nvim/fnl/toast/table.fnl
@@ -11,8 +11,18 @@
(table.insert t ...)
t)
+(fn concat [...]
+ "Join an arbitrary amount of tables.
+ Equivalent to a single 'layer' of flat."
+ (let [out []]
+ (each [_ xs (ipairs [...])]
+ (each [_ v (ipairs xs)]
+ (insert out v)))
+ out))
+
(local unpack (or table.unpack unpack))
{: from-pairs
: insert
- : unpack}
+ : unpack
+ : concat}