Jump to content

Determine if a string is collapsible: Difference between revisions

Frink
(Added XPL0 example.)
(Frink)
Line 1,445:
</pre>
 
=={{header|Frink}}==
<lang frink>collapse[str] := str =~ %s/(.)\1+/$1/g
 
lines = ["",
""""If I were two-faced, would I be wearing this one?" --- Abraham Lincoln """,
"..1111111111111111111111111111111111111111111111111111111111111117777888",
"I never give 'em hell, I just tell the truth, and they think it's hell. ",
" --- Harry S Truman "]
 
for line = lines
println[collapse[line]]</lang>
{{out}}
<pre>
 
"If I were two-faced, would I be wearing this one?" - Abraham Lincoln
.178
I never give 'em hel, I just tel the truth, and they think it's hel.
- Hary S Truman
</pre>
 
=={{header|Go}}==
494

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.