diff options
| author | 2024-08-07 21:51:15 +0200 | |
|---|---|---|
| committer | 2024-08-07 21:51:15 +0200 | |
| commit | 23d6644dbe76e22d8558657bfede7b5d471d6383 (patch) | |
| tree | 6ef0b96be5a3e840548d125a208bca4d262d8827 /dot_config/nvim/lua/toast/table.lua | |
| parent | nvim: 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/lua/toast/table.lua')
| -rw-r--r-- | dot_config/nvim/lua/toast/table.lua | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/dot_config/nvim/lua/toast/table.lua b/dot_config/nvim/lua/toast/table.lua index a898a5e..e9c1baf 100644 --- a/dot_config/nvim/lua/toast/table.lua +++ b/dot_config/nvim/lua/toast/table.lua @@ -2,9 +2,8 @@ local function from_pairs(t, _3fmut) local out = (_3fmut or {}) for _, _1_ in ipairs(t) do - local _each_2_ = _1_ - local k = _each_2_[1] - local v = _each_2_[2] + local k = _1_[1] + local v = _1_[2] out[k] = v end return out @@ -13,5 +12,14 @@ local function insert(t, ...) table.insert(t, ...) return t end +local function concat(...) + local out = {} + for _, xs in ipairs({...}) do + for _0, v in ipairs(xs) do + insert(out, v) + end + end + return out +end local unpack = (table.unpack or unpack) -return {["from-pairs"] = from_pairs, insert = insert, unpack = unpack} +return {["from-pairs"] = from_pairs, insert = insert, unpack = unpack, concat = concat} |
