Hi,
I am trying to write a function to return a boolean as to whether
parenthesis are balanced or not?
(defn bal-parens? [parens]
(let [replaced (clojure.string/replace parens "()" "")
checked (re-seq #"\(\)" replaced)]
(println checked)
(if-not (nil? checked) (bal-parens? replaced))
(println (str "replaced is " replaced))
(if (empty? replaced) true false)))
(bal-parens? "(()())")
I'd expect to see true here.
But my output is:
(())
nil
replaced is
replaced is ()
false
I can't for the life of me think why, that when checked is nil and replaced
is empty the function doesn't terminate!
Many Thanks
Aidy
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.