Determine if a string is collapsible: Difference between revisions

Boolean expression was a shame.
(Added Wren)
(Boolean expression was a shame.)
Line 1,456:
 
=={{header|Scala}}==
===Pure imperative programming===
 
<lang Scala> object CollapsibleString {
 
/**Collapse a string (if possible)*/
Line 1,477 ⟶ 1,478:
 
/**Check if a string is collapsible*/
def isCollapsible (s : String) : Boolean = if(collapseString(s).length =!= s.length) false else true
 
/**Display results as asked in the task*/
Line 1,510 ⟶ 1,511:
 
 
}</lang>
}
</lang>
 
{{out}}
<pre>ORIGINAL : length = 0, string = «««»»»
<pre>
ORIGINAL : length = 0, string = «««»»»
COLLAPSED : length = 0, string = «««»»»
This string is NOT collapsible !
Line 1,545 ⟶ 1,543:
ORIGINAL : length = 8, string = «««aardvark»»»
COLLAPSED : length = 7, string = «««ardvark»»»
This string IS collapsible !</pre>
</pre>
 
=={{header|Sidef}}==
Anonymous user