Balanced brackets: Difference between revisions

m
→‎{{header|RPL}}: reformatting
(GDScript)
m (→‎{{header|RPL}}: reformatting)
Line 6,760:
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
<syntaxhighlight lang="RPL">
'BALBKT'
1 OVER SIZE
'''WHILE''' DUP2 * 0 > '''REPEAT'''
3 PICK OVER DUP SUB
'''IF''' "[]" SWAP POS '''THEN'''
LAST 2 * 3 - ROT + SWAP '''END'''
ROT + SWAP
END
1 -
'''END''' DROP
1 SAME "" "Not " '''IFTE''' "OK" +
DROP
≫ ''''BALBKT'''' STO
1 SAME "" "Not " IFTE
"OK" +
≪ { "" "[]" "[][]" "[[][]]" "][" "][][" "[]][[]" } → ts
'ASSERT'
≪ {
""
"[]"
"[][]"
"[[][]]"
"]["
"][]["
"[]][[]" }
→ ts
1 ts SIZE '''FOR''' j
ts j GET '''BALBKT''' " → " SWAP + + '''NEXT'''
FOR j
≫ ≫ ''''TASK'''' STO
ts j GET BALBKT " → " SWAP + +
NEXT
</syntaxhighlight>
{{out}}
<pre>
ASSERT
" → OK"
"[] → OK"
1,150

edits