Determine if a string is collapsible: Difference between revisions

Content added Content deleted
m (→‎{{header|Factor}}: credit where credit's due)
Line 407: Line 407:
}</lang>
}</lang>
<lang zkl>strings:=
<lang zkl>strings:=
#<<<
0'^
0'^
"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln
"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln
Line 415: Line 414:
The American people have a right to know if their president is a crook.
The American people have a right to know if their president is a crook.
--- Richard Nixon
--- Richard Nixon
The better the 4-wheel drive, the further you'll be from help when ya get stuck!
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA^
headmistressship
aardvark^
.split("\n");
.split("\n");
#<<<
#<<<


foreach s in (strings){
foreach s in (strings){
println("Length: %3d >>>%s<<<".fmt(s.len(),s));
println("Before: %3d >>>%s<<<".fmt(s.len(),s));
c,cstr := collapsible(s);
_,cstr:=collapsible(s);
println("Collapsible: ",c);
println("After: %3d >>>%s<<<\n".fmt(cstr.len(),cstr));
println("Length: %3d >>>%s<<<\n".fmt(cstr.len(),cstr));
}</lang>
}</lang>
{{out}}
{{out}}
<pre>
<pre>
Length: 0 >>><<<
Before: 0 >>><<<
After: 0 >>><<<
Collapsible: False

Length: 0 >>><<<
Before: 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 <<<

Before: 72 >>>..1111111111111111111111111111111111111111111111111111111111111117777888<<<
After: 4 >>>.178<<<


Length: 72 >>>"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln <<<
Before: 72 >>>I never give 'em hell, I just tell the truth, and they think it's hell. <<<
After: 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 <<<


Before: 72 >>> --- Harry S Truman <<<
Length: 72 >>>..1111111111111111111111111111111111111111111111111111111111111117777888<<<
After: 17 >>> - Hary S Truman <<<
Collapsible: True
Length: 4 >>>.178<<<


Length: 72 >>>I never give 'em hell, I just tell the truth, and they think it's hell. <<<
Before: 72 >>>The American people have a right to know if their president is a crook. <<<
After: 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. <<<


Length: 72 >>> --- Harry S Truman <<<
Before: 72 >>> --- Richard Nixon <<<
After: 17 >>> - Richard Nixon <<<
Collapsible: True
Length: 17 >>> - Hary S Truman <<<


Length: 72 >>>The American people have a right to know if their president is a crook. <<<
Before: 80 >>>The better the 4-wheel drive, the further you'll be from help when ya 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 <<<


Before: 8 >>>aardvark<<<
Length: 72 >>>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<<<
After: 7 >>>ardvark<<<
Collapsible: True
Length: 1 >>>A<<<
</pre>
</pre>