Determine if a string is collapsible: Difference between revisions
Determine if a string is collapsible (view source)
Revision as of 23:19, 4 October 2021
, 2 years agoAdded 11l
(Added Racket implementation) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 80:
{{Template:Strings}}
<br><br>
=={{header|11l}}==
{{trans|Kotlin}}
<lang 11l>F collapse(s)
V cs = ‘’
V last = Char("\0")
L(c) s
I c != last
cs ‘’= c
last = c
R cs
V strings = [
‘’,
‘"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 ’,
‘The better the 4-wheel drive, the further you'll be from help when ya get stuck!’,
‘headmistressship’,
‘aardvark’
]
L(s) strings
V c = collapse(s)
print(‘original : length = ’s.len‘, string = <<<’s‘>>>’)
print(‘collapsed : length = ’c.len‘, string = <<<’c‘>>>’)
print()</lang>
{{out}}
<pre>
original : length = 0, string = <<<>>>
collapsed : length = 0, string = <<<>>>
original : length = 72, string = <<<"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln >>>
collapsed : length = 70, string = <<<"If I were two-faced, would I be wearing this one?" - Abraham Lincoln >>>
original : length = 72, string = <<<..1111111111111111111111111111111111111111111111111111111111111117777888>>>
collapsed : length = 4, string = <<<.178>>>
original : length = 72, string = <<<I never give 'em hell, I just tell the truth, and they think it's hell. >>>
collapsed : length = 69, string = <<<I never give 'em hel, I just tel the truth, and they think it's hel. >>>
original : length = 72, string = <<< --- Harry S Truman >>>
collapsed : length = 17, string = <<< - Hary S Truman >>>
original : length = 80, string = <<<The better the 4-wheel drive, the further you'll be from help when ya get stuck!>>>
collapsed : length = 77, string = <<<The beter the 4-whel drive, the further you'l be from help when ya get stuck!>>>
original : length = 16, string = <<<headmistressship>>>
collapsed : length = 14, string = <<<headmistreship>>>
original : length = 8, string = <<<aardvark>>>
collapsed : length = 7, string = <<<ardvark>>>
</pre>
=={{header|8080 Assembly}}==
Line 198 ⟶ 255:
<<< - Hary S Truman >>> 17
</pre>
=={{header|Ada}}==
|