diff options
Diffstat (limited to 'tex/context/base/l-table.lua')
-rw-r--r-- | tex/context/base/l-table.lua | 85 |
1 files changed, 3 insertions, 82 deletions
diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua index 67216d1f5..331bd9ca0 100644 --- a/tex/context/base/l-table.lua +++ b/tex/context/base/l-table.lua @@ -264,15 +264,11 @@ function table.is_empty(t) -- obolete, use inline code instead return not t or not next(t) end -function table.one_entry(t) -- obolete, use inline code instead +function table.has_one_entry(t) local n = next(t) return n and not next(t,n) end ---~ function table.starts_at(t) -- obsolete, not nice anyway ---~ return ipairs(t,1)(t,0) ---~ end - function table.tohash(t,value) local h = { } if t then @@ -694,7 +690,7 @@ function table.unnest(t) -- bad name return f end -table.flatten_one_level = table.unnest +table.flattenonelevel = table.unnest -- a better one: @@ -714,51 +710,6 @@ end table.flattened = flattened --- the next three may disappear - -function table.remove_value(t,value) -- todo: n - if value then - for i=1,#t do - if t[i] == value then - remove(t,i) - -- remove all, so no: return - end - end - end -end - -function table.insert_before_value(t,value,str) - if str then - if value then - for i=1,#t do - if t[i] == value then - insert(t,i,str) - return - end - end - end - insert(t,1,str) - elseif value then - insert(t,1,value) - end -end - -function table.insert_after_value(t,value,str) - if str then - if value then - for i=1,#t do - if t[i] == value then - insert(t,i+1,str) - return - end - end - end - t[#t+1] = str - elseif value then - t[#t+1] = value - end -end - local function are_equal(a,b,n,m) -- indexed if a and b and #a == #b then n = n or 1 @@ -873,7 +824,7 @@ function table.hexed(t,seperator) return concat(tt,seperator or " ") end -function table.reverse_hash(h) -- needs another name +function table.swaphash(h) -- needs another name local r = { } for k,v in next, h do r[v] = lower(gsub(k," ","")) @@ -891,36 +842,6 @@ function table.reverse(t) return tt end -function table.insert_before_value(t,value,extra) - for i=1,#t do - if t[i] == extra then - remove(t,i) - end - end - for i=1,#t do - if t[i] == value then - insert(t,i,extra) - return - end - end - insert(t,1,extra) -end - -function table.insert_after_value(t,value,extra) - for i=1,#t do - if t[i] == extra then - remove(t,i) - end - end - for i=1,#t do - if t[i] == value then - insert(t,i+1,extra) - return - end - end - insert(t,#t+1,extra) -end - function table.sequenced(t,sep,simple) -- hash only local s = { } for k, v in sortedhash(t) do |