21 lines
517 B
Plaintext
21 lines
517 B
Plaintext
procedure main()
|
|
write(lcdsubstr(["/home/user1/tmp/coverage/test","/home/user1/tmp/covert/operator","/home/user1/tmp/coven/members"]))
|
|
end
|
|
|
|
procedure lcdsubstr(sL,d) #: return the longest common sub-string of strings in the list sL delimited by d
|
|
local ss
|
|
|
|
/d := "/"
|
|
reverse(sL[1]) ? {
|
|
if tab(find(d)+*d) || allmatch(ss := reverse(tab(0)),sL) then
|
|
return ss
|
|
}
|
|
end
|
|
|
|
procedure allmatch(s,L) #: retrun s if it matches all strings in L
|
|
local x
|
|
every x := !L do
|
|
if not match(s,x) then fail
|
|
return s
|
|
end
|