Determine if a string is collapsible: Difference between revisions

m
m (→‎{{header|Factor}}: credit where credit's due)
Line 407:
}</lang>
<lang zkl>strings:=
#<<<
0'^
"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln
Line 415 ⟶ 414:
The American people have a right to know if their president is a crook.
--- Richard Nixon
The better the 4-wheel drive, the further you'll be from help when ya get stuck!
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA^
headmistressship
aardvark^
.split("\n");
#<<<
 
foreach s in (strings){
println("LengthBefore: %3d >>>%s<<<".fmt(s.len(),s));
c_,cstr := collapsible(s);
println("CollapsibleAfter: %3d >>>%s<<<\n".fmt(cstr.len(),ccstr));
println("Length: %3d >>>%s<<<\n".fmt(cstr.len(),cstr));
}</lang>
{{out}}
<pre>
LengthBefore: 0 >>><<<
LengthAfter: 0 0 >>><<<
Collapsible: False
 
Length: 0 >>><<<
LengthBefore: 70 72 >>>"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln <<<
After: 70 >>>"If I were two-faced, would I be wearing this one?" - Abraham Lincoln <<<
 
LengthBefore: 72 >>>..1111111111111111111111111111111111111111111111111111111111111117777888<<<
LengthAfter: 4 4 >>>.178<<<
 
LengthBefore: 72 >>>"If I werenever two-faced,give would'em hell, I bejust wearingtell the truth, thisand one?"they ---think Abrahamit's Lincolnhell. <<<
LengthAfter: 69 69 >>>I never give 'em hel, I just tel the truth, and they think it's hel. <<<
Collapsible: True
Length: 70 >>>"If I were two-faced, would I be wearing this one?" - Abraham Lincoln <<<
 
LengthBefore: 72 >>> --- RichardHarry NixonS Truman <<<
Length: 72 >>>..1111111111111111111111111111111111111111111111111111111111111117777888<<<
LengthAfter: 17 17 >>> - Hary S Truman <<<
Collapsible: True
Length: 4 >>>.178<<<
 
LengthBefore: 72 >>>I neverThe giveAmerican 'empeople hell,have Ia justright tellto theknow truth,if andtheir theypresident thinkis it'sa hellcrook. <<<
LengthAfter: 71 71 >>>The American people have a right to know if their president is a crok. <<<
Collapsible: True
Length: 69 >>>I never give 'em hel, I just tel the truth, and they think it's hel. <<<
 
LengthBefore: 72 >>> --- HarryRichard SNixon Truman <<<
LengthAfter: 17 17 >>> - Richard Nixon <<<
Collapsible: True
Length: 17 >>> - Hary S Truman <<<
 
LengthBefore: 72 80 >>>The Americanbetter peoplethe have4-wheel adrive, rightthe tofurther knowyou'll ifbe theirfrom presidenthelp iswhen aya crook.get stuck!<<<
After: 77 >>>The beter the 4-whel drive, the further you'l be from help when ya get stuck!<<<
Collapsible: True
Length: 71 >>>The American people have a right to know if their president is a crok. <<<
 
Before: 16 >>>headmistressship<<<
Length: 72 >>> --- Richard Nixon <<<
After: 14 >>>headmistreship<<<
Collapsible: True
Length: 17 >>> - Richard Nixon <<<
 
LengthBefore: 1 8 >>>Aaardvark<<<
Length: 72 >>>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<<<
After: 7 >>>ardvark<<<
Collapsible: True
Length: 1 >>>A<<<
</pre>
Anonymous user