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 --- list.lua | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 list.lua (limited to 'list.lua') diff --git a/list.lua b/list.lua deleted file mode 100644 index 1153c26..0000000 --- a/list.lua +++ /dev/null @@ -1,48 +0,0 @@ ---- lam.list - -local list = {} -local util = require "util" -local types = require "types" -table.unpack = table.unpack or unpack - -list.Null = setmetatable({}, { - __type = "Null", - __tostring = function(self) return "()" end, -}) - -list.isNull = - function (x) - return x == list.Null - end - -list.List = - function (tbl) - local function tolist (base, items) - if #items == 0 then return base end - return tolist ( - types.Cons(table.remove(items), base), - items - ) - end - return tolist(list.Null, tbl) - end - -list.isList = - function (x) - if list.isNull(x) then - return true - elseif types.isa(x, "Pair") then - return list.isList(x[2]) - else - return false - end - end - -list.fold1 = - function (fn, seed, lis) - if list.isNull(lis) then return seed end - return list.fold1(fn, fn(seed, lis[1]), lis[2]) - end - ---- -return list -- cgit 1.4.1-21-gabe81