If I do the following in clojure
(defn sub1a [a]
(cond
(= a 0) 0
true (sub1b (- a 1) )))
(defn sub1b [a]
(cond
(= a 0) 0
true (sub1a (- a 1) )))
(println (sub1a 10))
I get the following error:
java.lang.Exception: Unable to resolve symbol: sub1b in this context
But if I do the following:
(defn sub1a [a]
(cond
(= a 0) 0
true (- a 1)))
(defn sub1b [a]
(cond
(= a 0) 0
true (- a 1)))
(defn sub1a [a]
(cond
(= a 0) 0
true (sub1b (- a 1) )))
(defn sub1b [a]
(cond
(= a 0) 0
true (sub1a (- a 1) )))
(println (sub1a 10))
It runs just fine.
Is this by design, or just a function of the way the Clojure reader works?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With