I want to merge lines that share common prefix. Example:
a 1
a 2
bc-de 3 4
bc-de 5
After merging:
I want to merge lines that share common prefix. Example:
a 1
a 2
bc-de 3 4
bc-de 5
After merging:
I want to merge lines that share common prefix. Example:
a 1
a 2
bc-de 3
bc-de 4
bc-de 5
After merging:
a-a 12 34 12
a-a-a 56 56
a-ba-ao-ke-luo 78 90 90
Each line is a key values pattern. The key is a string delimited by hyphens. while values delimited by spaces.
I want to remove duplicate vlaues on each line:
[cplayer] Reading config file /home/zachary/.config/mpv/mpv.conf
[cplayer] Setting option 'no-border' = '' (flags = 4)
[cplayer] Setting option 'ontop' = 'no' (flags = 4)
[cplayer] Setting option 'save-position-on-quit' = 'yes' (flags = 4)
[cplayer] Setting option 'autofit-larger' = '100%' (flags = 4)
[cplayer] Setting option 'profile' = 'pseudo-gui' (flags = 4)
[cplayer] Setting option 'terminal' = 'no' (flags = 4)
libva info: VA-API version 0.38.1
libva info: va_getDriverName() returns 0
-- deeply compare two objects like 'pl.tablex.deepcompare()' | |
local function deep_equals(t1, t2, ignore_mt) | |
-- different type | |
if t1Type ~= t2Type then return false end | |
-- compare simple values directly | |
if t1Type ~= 'table' then return t1 == t2 end | |
-- both table type; try metatable method | |
if not ignore_mt then | |
local mt1 = getmetatable(t1) |
local function list_iter (t) | |
local i = 0 | |
local n = #t | |
return function () | |
i = i + 1 | |
if i <= n then return t[i] end | |
end | |
end | |
local t = { 10, 20, 30 } |
-- memory test | |
local size = 1000000 | |
local t = {} -- create a table | |
local function report(title) | |
collectgarbage() | |
collectgarbage() | |
print(title, collectgarbage("count")) | |
end |
local socket = require("socket") | |
local host, port = "180.101.50.242", 80 | |
local sock = socket.connect(host, port) | |
sock:settimeout(1) | |
sock:send("GET / HTTP/1.1\r\n\r\n") | |
sock:close() |
local func -- Forward declaration. `local func = nil` is the same. | |
local function func2() -- Suppose you can't move this function lower. | |
return func() -- reference to name, not to its value | |
end | |
-- error | |
print(func2()) | |
function func() -- defined here |