From a72ff678da253fce46e8e4648f6e4cf5ce1ea9b4 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 10 Mar 2024 21:39:53 -0500 Subject: uh new start --- util.lua | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'util.lua') diff --git a/util.lua b/util.lua index 1059edf..938848c 100644 --- a/util.lua +++ b/util.lua @@ -1,42 +1,11 @@ --- lam.util local util = {} -table.unpack = table.unpack or unpack - -function util.table (x) - if type(x) == "table" then - return x - else - return { x } - end -end +local unpack = table.unpack or unpack function util.pop (tbl) return table.remove(tbl, 1) end -function util.car (tbl) - return tbl[1] -end - -function util.cdr (tbl) - local t = {} - for i = 2, #tbl do t[i-1] = tbl[i] end - return t -end - -function util.reduce (tbl, seed, fn) - if #tbl == 0 then return seed end - return util.reduce(tbl, fn(seed, util.pop(tbl)), fn) -end - -function util.map (fn, tbl) - local out = {} - for k, v in pairs(tbl) do - out[k] = fn(v) - end - return out -end - --- return util -- cgit 1.4.1-21-gabe81