Balanced brackets: Difference between revisions

→‎{{header|Julia}}: another solution
(Improved third D entry)
(→‎{{header|Julia}}: another solution)
Line 2,143:
("]]][][[[][][[]",false)
("[[[[[][]]]]]][[]",false)</pre>
A short solution, using mapreduce.
<lang julia>balanced(str) = mapreduce(x-> (x=='[')-(x==']'), (x,y)-> x<0? -1: x+y, str) == 0</lang>
 
=={{header|Liberty BASIC}}==