Re: How to move an element within a vector?

2019-08-30 Thread Sébastien Béal
This is a old post but I made a few simple helpers to work with vectors that would solve your problem I believe: https://gist.github.com/sebastibe/27be496c34ba6a3cce3b6425810a3dda On Wednesday, August 26, 2015 at 2:06:30 AM UTC+9, Hussein B. wrote: > > Hi, > > For a vector like [A B C D E],

Re: How to move an element within a vector?

2015-08-26 Thread Linus Ericsson
It is correct that vectors aren't a suitable choice for datastructures that need random-access-removal. The problem is that you seem to need both fast index lookup and be able to access elements after removed elements quickly even when there are holes in the backing array. There are some

How to move an element within a vector?

2015-08-25 Thread Hussein B.
Hi, For a vector like [A B C D E], how to remove an element to a specific location? For example [A D B C E] ? I thought about converting the vector into array but I would feel bad if I did that. What would be the idiomatic way to do that in Clojure? Thanks for help and time. -- You

Re: How to move an element within a vector?

2015-08-25 Thread Fluid Dynamics
On Tuesday, August 25, 2015 at 1:06:30 PM UTC-4, Hussein B. wrote: Hi, For a vector like [A B C D E], how to remove an element to a specific location? For example [A D B C E] ? How about (assoc (assoc v j (v i)) i (v j)), once you have the indices i and j of two elements you wish to swap?

Re: How to move an element within a vector?

2015-08-25 Thread Georgi Danov
How about filtering? BTW I don't see how it would help converting to array - what would be the solution then? On Tuesday, August 25, 2015 at 7:06:30 PM UTC+2, Hussein B. wrote: Hi, For a vector like [A B C D E], how to remove an element to a specific location? For example [A D B C E] ?