Balanced brackets: Difference between revisions
m
→Functional JS: Tested and refreshed output.
(→Functional JS: Generalised the code a little. (Other bracket types, mixed strings)) |
m (→Functional JS: Tested and refreshed output.) |
||
Line 3,373:
iNext = iDepth + (
strBrackets.includes(h) ? (
openBracket ===
1
) : -1
Line 3,403:
const
stringLength = 2 * pairCount,
return "'" +
strPad.slice(2 + stringLength) + maybe('OK')(
iUnMatched => 'problem\n' +
' '.repeat(1 + iUnMatched) + '^'
)(
findUnbalancedBracket('[]')(
);
}).join('\n')
Line 3,452:
})();</lang>
{{Out}}
<pre>'' OK
'[]' OK
'[]
^
'[]]][[' problem
^
'[][[]
^
'[][[
']]][[][]
^</pre>
|