Jump to content

Determine if a string is collapsible: Difference between revisions

→‎{{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" -- "string" )''
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.
≪ { ""
{{in}}
"≪ If I were two-faced, would I be wearing this one? ≫ --- Abraham Lincoln "
<pre>
"..1111111111111111111111111111111111111111111111111111111111111117777888"
≪ { ""
"I Ifnever Igive were'em two-facedhell, would I bejust wearingtell thisthe truth, one?and they ---think Abrahamit's Lincolnhell. "
" --- Harry S Truman " }
"..1111111111111111111111111111111111111111111111111111111111111117777888"
1 5 '''FOR''' j DUP j GET <span style="color:blue">CLAPS</span> SWAP '''NEXT''' DROP
"I never give 'em hell, I just tell the truth, and they think it's hell. "
≫ EVAL
" --- Harry S Truman " }
1 5 FOR j DUP j GET CLAPS SWAP NEXT DROP
≫ EVAL
</pre>
{{out}}
<pre>
1,150

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.