title: How to remove elements from a vector in a fast way in Clojure?
body: <p>I'm trying to remove elements from a Clojure vector:</p>
  
  <blockquote>
    <p>Note that I'm using Clojure's operations from Kotlin</p>
  </blockquote>
  
  <pre><code>val set = PersistentHashSet.create("foo")
  val vec = PersistentVector.create("foo", "bar")
  val seq = clojure.`core$remove`.invokeStatic(set, vec) as ISeq
  val resultVec = clojure.`core$vec`.invokeStatic(seq) as PersistentVector
  </code></pre>
  
  <p>This is the equivalent of the following Clojure code:</p>
  
  <pre><code>(remove #{"foo"} ["foo" "bar"])
  </code></pre>
  
  <p>The code works fine but I've noticed that creating a vector from the seq is extrmely slow. I've written a benchmark and these were the results:</p>
  
  <pre><code>| Item count | Remove ms | Remove with converting back to vector ms|
  -----------------------------------------------------------------
  | 1000       | 51        | 1355                                 |
  | 10000      | 71        | 5123                                 |
  </code></pre>
  
  <p>Do you know how I can convert the <code>seq</code> resulting from the <code>remove</code> operation back to a <code>vector</code> without the harsh performance penalty?</p>
  
  <p>If it is not possible is there an alternative way to perform the <code>remove</code> operation? </p>