Stuck on #65 Black box testing

275 views
Skip to first unread message

Justin Heyes-Jones

unread,
Oct 19, 2012, 8:59:46 PM10/19/12
to 4clo...@googlegroups.com
I finally came up with a solution for #65 and it turns out I'm not allowed to use catch? Why is that? I'm sad because now I'm out of ideas.

(defn id-type [coll]
  (try
    (assoc coll :a 1)
    :map
    (catch Exception e
      (try
        (subvec coll 0)
        :vec
        (catch Exception e
          (try
            (nth coll 0)
            :list
            (catch Exception e
              :set)))))))

Tom Chappell

unread,
Oct 19, 2012, 11:43:50 PM10/19/12
to 4clo...@googlegroups.com
You're probably being stymied by either the jail or because 4clojure runs on an old verison of Clojure (1.2 the last I checked).

I solved this one not by try/catch but by looking for other characteristic differences in the behavior of the item being tested.  Not very specific, I know.

-TC

ctzsm

unread,
Oct 20, 2012, 9:29:16 AM10/20/12
to 4clo...@googlegroups.com
Hi,

The clojure version of 4clojure's sandbox is 1.4.0, try the following code

(= (clojure-version) "1.4.0")

to pass problem 1 to check it.

And there are more than 3 ways to solve problem 65, just keep thinking, any kind of hint may spoil it.

Justin Heyes-Jones

unread,
Oct 20, 2012, 7:03:04 PM10/20/12
to 4clo...@googlegroups.com
Thanks guys I'll keep plugging away

Justin Heyes-Jones

unread,
Oct 20, 2012, 10:05:42 PM10/20/12
to 4clo...@googlegroups.com
Phew, figured it out again without exceptions. 

It's not really a hint but reading this page carefully helped a lot. 

Reply all
Reply to author
Forward
0 new messages