Q:

seq to vec conversion - Key must be integer

I want to get the indices of nil elements in a vector eg.
[1 nil 3 nil nil 4 3 nil] => [1 3 4 7] 
(defn nil-indices [vec]
  (vec (remove nil? (map
    #(if (= (second %) nil) (first %))
      (partition-all 2 (interleave (range (count vec)) vec)))))
  )

Running this code results in

java.lang.IllegalArgumentException: Key must be integer
  (NO_SOURCE_FILE:0)

If I leave out the (vec) call surrounding everything, it seems to work, but returns a sequence instead of a vector.
Thank you!

A:

Try this instead:
(defn nil-indices [v]
  (vec (remove nil? (map
    #(if (= (second %) nil) (first %))
      (partition-all 2 (interleave (range (count v)) v))))))

Clojure is a LISP-1: It has a single namespace for both functions and data, so when you called (vec ...), you were trying to pass your result sequence to your data as a parameter, not to the standard-library vec function.

