Created
November 27, 2011 19:19
-
-
Save damionjunk/1398012 to your computer and use it in GitHub Desktop.
Naively balance a string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn str-b-balance | |
"Naive bracket balance in the provided string." | |
[s & {:keys [ls rs] :or {ls \[ rs \]}}] | |
(let [bc (b-closers s)] | |
(reduce (fn [st ch] | |
(if (= ls ch) (str ch st) (str st ch))) | |
s | |
bc))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment