Determine if a string is collapsible: Difference between revisions
Determine if a string is collapsible (view source)
Revision as of 20:22, 25 November 2023
, 6 months ago→{{header|RPL}}: HP-49 version
(Added Easylang) |
(→{{header|RPL}}: HP-49 version) |
||
Line 3,414:
=={{header|RPL}}==
{{trans|Kotlin}}▼
{{works with|Halcyon Calc|4.2.7}}
▲{{trans|Kotlin}}
{| class="wikitable"
! RPL code
Line 3,423:
≪ → string
≪ "" DUP
1 string SIZE '''FOR''' j
string j DUP SUB
'''IF''' DUP2 ≠ '''THEN'''
Line 3,430:
'''END''' DROP
'''NEXT''' DROP
≫ ≫ ‘'''<span style="color:blue">CLAPS</span>'''’ STO
|
'''<span style="color:blue">CLAPS</span>''' ''( "strrinng"
output string = last = ""
scan the input string
Line 3,443:
|}
{{works with|HP|49}}
« → string
string SIZE 1 '''FOR''' j
string j DUP SUB SWAP
'''IF''' DUP2 HEAD == '''THEN''' NIP '''ELSE''' + '''END'''
-1 '''STEP'''
∑LIST
» » ‘'''<span style="color:blue">CLAPS</span>'''’ STO
When displaying strings, RPL always adds double quotes. To fulfill the artistic touch requirement, we have used guillemets to bracket Lincoln's statement.
≪ { ""
"≪ If I were two-faced, would I be wearing this one? ≫ --- Abraham Lincoln "
"..1111111111111111111111111111111111111111111111111111111111111117777888"▼
▲≪ { ""
"
" --- Harry S Truman " }▼
▲ "..1111111111111111111111111111111111111111111111111111111111111117777888"
1 5 '''FOR''' j DUP j GET <span style="color:blue">CLAPS</span> SWAP '''NEXT''' DROP▼
≫ EVAL▼
▲ " --- Harry S Truman " }
▲ 1 5 FOR j DUP j GET CLAPS SWAP NEXT DROP
▲≫ EVAL
{{out}}
<pre>
|