langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -0,0 +1,42 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const func integer: commonLen (in array string: names, in char: sep) is func
|
||||
result
|
||||
var integer: result is -1;
|
||||
local
|
||||
var integer: index is 0;
|
||||
var integer: pos is 1;
|
||||
begin
|
||||
if length(names) <> 0 then
|
||||
repeat
|
||||
for index range 1 to length(names) do
|
||||
if pos > length(names[index]) or names[index][pos] <> names[1][pos] then
|
||||
decr(pos);
|
||||
while pos >= 1 and names[1][pos] <> sep do
|
||||
decr(pos);
|
||||
end while;
|
||||
if pos > 1 then
|
||||
decr(pos);
|
||||
end if;
|
||||
result := pos;
|
||||
end if;
|
||||
end for;
|
||||
incr(pos);
|
||||
until result <> -1;
|
||||
end if;
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var integer: length is 0;
|
||||
const array string: names is [] ("/home/user1/tmp/coverage/test",
|
||||
"/home/user1/tmp/covert/operator",
|
||||
"/home/user1/tmp/coven/members")
|
||||
begin
|
||||
length := commonLen(names, '/');
|
||||
if length = 0 then
|
||||
writeln("No common path");
|
||||
else
|
||||
writeln("Common path: " <& names[1][.. length]);
|
||||
end if;
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue