Anonymous user
Longest common prefix: Difference between revisions
m
→version 3: added whitespace.
m (→version 2: added whitespace.) |
m (→version 3: added whitespace.) |
||
Line 2,847:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
LCP: @= arg(1); m= length(@); #=arg(); say copies('▒', 60)
say '────────────── number of strings specified:' #
do i=1 for #; say '────────────── string' i":" showNull(arg(i))
end /*i*/
do j=2 to #; x= arg(j);
if t==1 | x=='' then do; @=; leave; end
if t==0 & @==x then t= length(@) + 1
if t>=m then iterate /*not longest str.*/
m= t - 1; @= left(@, max(0, m)
end /*j*/
return ' longest common prefix=' shownull(@
/*──────────────────────────────────────────────────────────────────────────────────────*/
showNull: procedure; parse arg z; if z=='' then z= "«null»"; return z</lang>
<pre>
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
|