Determine if a string is collapsible: Difference between revisions
m
→{{header|Phix}}: sigh :-)
m (→{{header|REXX}}: changed whitespace.) |
m (→{{header|Phix}}: sigh :-)) |
||
Line 1,113:
string ti = tests[i], ci = unique(ti, "PRESORTED")
printf(1,fmt,{length(ti),ti,length(ci),ci})
end for
function collapsible(string t)
for i=2 to length(t) do
if t[i]=t[i-1] then
return true
end if
end for
return false
end function
puts(1,"\nAs predicate: ")
for i=1 to length(tests) do
printf(1,"%t ",collapsible(tests[i]))
end for
puts(1,"\n")</lang>
{{out}}
<pre>
Line 1,130 ⟶ 1,145:
length 72 input: <<< --- Harry S Truman >>>
length 17 output: <<< - Hary S Truman >>>
As predicate: false true true true true
</pre>
|