Determine if a string is collapsible: Difference between revisions

Content added Content deleted
No edit summary
(Added Quackery.)
Line 2,067: Line 2,067:
{{Out}}
{{Out}}
<pre>[False, True, True, True, True, True, True, True, True, False]</pre>
<pre>[False, True, True, True, True, True, True, True, True, False]</pre>

=={{header|Quackery}}==

<lang Quackery> [ false -1 rot
witheach
[ 2dup = iff
[ drop dip not
conclude ]
else nip ]
drop ] is collapsible ( $ --> b )
[ [] -1 rot
witheach
[ 2dup = iff drop
else
[ nip dup dip join ] ]
drop ] is collapse ( $ --> $ )

[ dup collapsible iff
[ dup collapse
swap 2 ]
else
[ say "(Not collapsible.)" cr
1 ]
times
[ say "<<<"
dup echo$
say ">>>" cr
say " Length: "
size echo
say " characters" cr cr ]
cr ] is task ( $ --> )

$ "" task
$ '"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln ' task
$ "..1111111111111111111111111111111111111111111111111111111111111117777888" task
$ "I never give 'em hell, I just tell the truth, and they think it's hell. " task
$ " --- Harry S Truman " task</lang>

{{out}}

<pre>(Not collapsible.)
<<<>>>
Length: 0 characters


<<<"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln >>>
Length: 72 characters

<<<"If I were two-faced, would I be wearing this one?" - Abraham Lincoln >>>
Length: 70 characters


<<<..1111111111111111111111111111111111111111111111111111111111111117777888>>>
Length: 72 characters

<<<.178>>>
Length: 4 characters


<<<I never give 'em hell, I just tell the truth, and they think it's hell. >>>
Length: 72 characters

<<<I never give 'em hel, I just tel the truth, and they think it's hel. >>>
Length: 69 characters


<<< --- Harry S Truman >>>
Length: 72 characters

<<< - Hary S Truman >>>
Length: 17 characters


</pre>


=={{header|Raku}}==
=={{header|Raku}}==