On Apr 27, 2010, at 2:45 PM, Sean Devlin wrote:
You're right, inserting into a vector is fundamentally slow.
Inserting into a list (must traverse elements) or String (Char Array)
isn't any better. I get why Clojure doesn't include certain
operations on certain data structures (e.g. assoc on a
On Apr 27, 7:45 pm, Sean Devlin wrote:
> However, there are still problems
> that require me to use an expensive operation.
Could you give an example of such a problem? There may be another way
of solving it you have not considered.
- James
--
You received this message because you are subscrib
On Tue, Apr 27, 2010 at 3:41 PM, Mark J. Reed wrote:
> I'm a bit surprised that it's not there already, at least in
> clojure.contrib, but it's not hard to write, at least for vectors:
>
> (defn insert [vec pos item]
> (apply merge (subvec vec 0 pos) item (subvec vec pos)))
>
Er, that should
I'm a bit surprised that it's not there already, at least in
clojure.contrib, but it's not hard to write, at least for vectors:
(defn insert [vec pos item]
(apply merge (subvec vec 0 pos) item (subvec vec pos)))
On Tue, Apr 27, 2010 at 2:45 PM, Sean Devlin wrote:
> You're right, inserting i
You're right, inserting into a vector is fundamentally slow.
Inserting into a list (must traverse elements) or String (Char Array)
isn't any better. I get why Clojure doesn't include certain
operations on certain data structures (e.g. assoc on a list), because
it's the wrong tool for the job. Howe
On Tue, Apr 27, 2010 at 1:31 PM, Sean Devlin wrote:
> Is there a built in to insert a value into an "indexed" seq?
>
> For example:
>
> user=> (insert [:a :b :c :d] 2 :q)
> (:a :b :q :c :d)
>
> Not sure if I'm missing something simple...
That's a vector, which cannot efficiently splice internally
Also, why does this work:
user=> (assoc [:a :b :c :d] 2 :q)
[:a :b :q :d]
And this doesn't:
user=> (dissoc [:a :b :c :d] 2)
#
Annoying.
On Apr 27, 1:24 pm, Sean Devlin wrote:
> Is there a built in to insert a value into an "indexed" seq?
>
> For example:
>
> user=> (insert [:a :b :c :d] 2 :q)
Is there a built in to insert a value into an "indexed" seq?
For example:
user=> (insert [:a :b :c :d] 2 :q)
(:a :b :q :c :d)
Not sure if I'm missing something simple...
Sean
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, se