RosettaCodeData/Task/Longest-string-challenge/Phix/longest-string-challenge-1.phix
2016-12-05 23:44:36 +01:00

23 lines
496 B
Text

integer fn = open(command_line()[2],"r") -- (reading the source file)
function allx(string line)
line[1..-1] = 'x'
return line
end function
function longest(string mask)
object line = gets(fn)
string newmask
if atom(line) then return mask end if
newmask = allx(line)
if not match(mask,newmask) then return longest(mask) end if
mask = longest(newmask)
if match(mask,newmask) then
puts(1,line)
end if
return mask
end function
?longest("x")
close(fn)