How can I remove the nth item in a collection? I want to do something like this:
(def coll [:apple :banana :orange])
(drop-nth 0 coll) ;=> [:banana :orange]
(drop-nth 1 coll) ;=> [:apple :orange]
(drop-nth 2 coll) ;=> [:apple :banana]
Is there a better way to do this than what I have come up with so far?
(defn drop-nth [n coll]
(concat (take n coll) (nthrest coll (inc n))))
source
share