by sirclueless · 13y ago · 0 comments
As an example:
"But watch out if you try to pop nothing"
(= __ (try
(pop '())
(catch IllegalStateException e "No dice!")))
That code causes an error that looks like this: Problem in /home/clueless/clojure-koans/src/koans/02_lists.clj
---------------------
Assertion failed!
But watch out if you try to pop nothing
(= __ (try (pop (quote ())) (catch IllegalStateException e "No dice!")))
That's just a transliteration of the Clojure expression from my source code. It's not even as good as a line number, because it's not greppable. If I were actually to encounter this in a failing test, you had better believe I would want to know what the right-hand-side actually evaluated to in context, not just what the compiled expression looks like.I agree it does make it easier to solve when you can see what you're trying to evaluate to. It was actually a conscious decision to make that not be the case, because it seemed too easy to just fill in the blanks without thinking about what should go there.
This is basically the worst part of Clojure (and only on the JVM at that): catching a Java exception.
I know that's not your point but --and I'm a huge Clojure fan-- seeing a Java idiosynchrasy like that one makes me want to give up Clojure : (
"Conjoining an element to a list can be done in the reverse order"
(= __ (conj '(:a :b :c :d :e) 0))
Well OK, so is `conj` just `cons` with reversed argument order, or does it append to the other end of the list? My Lisp intuition tells me that the first is more likely, but the test failure doesn't show you anything, you have to use trial and error or fire up a REPL.e.g. (conj '(:a :b :c) :d :e :f) returns (:f :e :d :a :b :c)