vectorclojure# Clojure Remove item from Vector at a Specified Location

Is there a way to remove an item from a vector based on index as of now i am using subvec to split the vector and recreate it again. I am looking for the reverse of assoc for vectors?

Solution

`subvec`

is probably the best way. The Clojure docs say `subvec`

is "*O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done*". The alternative would be walking the vector and building a new one while skipping certain elements, which would be slower.

Removing elements from the middle of a vector isn't something vectors are necessarily good at. If you have to do this often, consider using a hash-map so you can use `dissoc`

.

See:

- On a mac, bash scripting shows uncertain behaviour w associative array (dictionaries)
- Is there a way to further optimize this code?
- Fill elements of a vector randomly depending on constraints
- expected ';' at end of declaration /vector /c++
- Is there an option to create a vector that contains functions with different return types?
- How to find a series of number in a vector using a loop for - R
- SceneKit physicBody angularVelocity as local "body fixed" angular rates
- R: Trouble subsetting a vector for use with trapz function (pracma package)
- i am writing a small interpreter in c++, but it returns me an error "vector subscript out of range"
- Redis Vector Radius Search
- Iterating C++ vector from the end to the beginning
- emplace_back and push_back give 'double free or corruption (fasttop)' error although copy and move constructor are defined
- Searching for multiple elements using std::find()
- Attempting to build Dynamic Array from scratch: Segmentation Fault when using delete[] in append function
- Angles between two n-dimensional vectors in Python
- leaflet tiles with protomaps pmtiles are not visibles (seems to be transparent)
- OpenAI Embeddings API: How to extract the embedding vector?
- Are there any existed API to split IEnumerable<T> to many Vector<T> in CSharp？
- How do I sort array of pairs based on the greater value in first or second
- How do I make a matrix from a list of vectors in R?
- Vector insert function not inserting from the range specified
- read csv string into vector C++
- Conversion of 2d vector to torch::tensor doesn't have the right data in C++
- Finding the lowest missing integer in a vector containing positive and negative int's?
- Why not overload operator+=() for std::vector?
- Generating vectors of consecutive map element subsets in C++
- get diagnostic data from ECU use python-uds
- Grab always n elements from vector, if vector length <n, loop over vector again
- rust increase the capacity of a vector by n
- Store cout from function as string