Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Incorrect 'count' alarm trip on problem #22 #219

bryndivey opened this Issue · 3 comments

2 participants


The following code:

(fn [xs]
    (reduce + (for [x xs] 1)))

triggered the 'count' trip alarm on problem number 22.


The problem is that for is a macro and expands to code that uses count. 4clojure's sandbox has to expand macros to look for blacklisted things. It is an unfortunate side effect that for doesn't work here.

Luckily, you can write it in many different ways.

(fn [xs] (reduce + (map (fn [_] 1) xs)))

Is your exact code written with map. There are other ways to solve this problem, but that's the exercise to the reader. :)

@Raynes Raynes closed this

Thanks Raynes, that makes sense - I haven't internalized Clojure's macros' contents yet. My second choice was
(reduce + (map #(1) xs))
which was a bit Pythonesque and didn't work here (no binding for the argument to the lambda, I assume), so it's nice to be pointed out that an anon func with a throw-away would also work.


#(1) doesn't work because it is equivalent to (fn [] (1)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.