diff options
| author | rebecca <ubq323@ubq323.website> | 2026-09-26 21:47:15 +0100 |
|---|---|---|
| committer | rebecca <ubq323@ubq323.website> | 2026-09-26 21:47:15 +0100 |
| commit | f5967d9f35eaaeb8ac797f91c03d98b54841516c (patch) | |
| tree | 2382a249e99a3bc1078be325c1a331e7782a3ec8 /set.lua | |
| parent | 5107345463be25bc471274bc82c503ba2acdf5b4 (diff) | |
delete Set because it is bad and replace it with table.keydiff which will be good and not bad
Diffstat (limited to 'set.lua')
| -rw-r--r-- | set.lua | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/set.lua b/set.lua deleted file mode 100644 index ae79ff1..0000000 --- a/set.lua +++ /dev/null @@ -1,20 +0,0 @@ -local class = require'r.class' -local Set = class() -function Set.make(cls, items) return setmetatable({_=items or {}},cls) end -function Set.has(self, item) return self._[item] end -function Set.add(self, item) self._[item] = true end -function Set.del(self, item) self._[item] = nil end -function Set.each(self) return pairs(self._) end -function Set.one(self) return next(self._) end -function Set.__len(self) local i = 0 for k in self:each() do i=i+1 end return i end -function Set.copy(self) local o={} for k in self:each() do o[k]=true end return Set(o) end -function Set.union(self,other) local o=self:copy() if other == nil then return o end - for k in other:each() do o:add(k) end return o end -function Set.insect(self,other) local o=self:copy() if other == nil then return o end - for k in o:each() do if not other:has(k) then o:del(k) end end return o end -function Set.diff(self,other) local o,p = self:copy(), other:copy() - for k in self:each() do p:del(k) end - for k in other:each() do o:del(k) end - return o,p end -return Set - |
