Determine if a string is collapsible: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: changed whitespace.) |
m (→{{header|Phix}}: sigh :-)) |
||
Line 1,113: | Line 1,113: | ||
string ti = tests[i], ci = unique(ti, "PRESORTED") |
string ti = tests[i], ci = unique(ti, "PRESORTED") |
||
printf(1,fmt,{length(ti),ti,length(ci),ci}) |
printf(1,fmt,{length(ti),ti,length(ci),ci}) |
||
end for |
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}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,130: | Line 1,145: | ||
length 72 input: <<< --- Harry S Truman >>> |
length 72 input: <<< --- Harry S Truman >>> |
||
length 17 output: <<< - Hary S Truman >>> |
length 17 output: <<< - Hary S Truman >>> |
||
As predicate: false true true true true |
|||
</pre> |
</pre> |
||