(transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast
exception. Is this expected/unavoidable? How do I know whether the
vectors I'm passed are regular vectors or come via subvec?
I'm assuming I lose all the performance benefits of subvec if I
defensively pour all vectors into a new vector
Check this out: http://clojure.org/Transients
On Apr 29, 10:54 am, Nathan Sorenson wrote:
> (transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast
> exception. Is this expected/unavoidable? How do I know whether the
> vectors I'm passed are regular vectors or come via subvec?
>
> I'm assumi
I've read that, and the claim seems to be that Vectors support
transience. Within Clojure's abstraction SubVectors are Vectores:
(vector? (subvec [1 2 3] 0 2)) => true.
On Apr 30, 8:27 am, Armando Blancas wrote:
> Check this out:http://clojure.org/Transients
>
> On Apr 29, 10:54 am, Nathan Sorens
On Sat, Apr 30, 2011 at 11:27 AM, Armando Blancas
wrote:
> On Apr 29, 10:54 am, Nathan Sorenson wrote:
>> (transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast
>> exception. Is this expected/unavoidable? How do I know whether the
>> vectors I'm passed are regular vectors or come via subvec
Yes but the contract of subvec is that it returns a "persistent
vector" and the resulting data structure returns "true" under the
"vector?" predicate. I know that subvec returns a different type
because I've looked at the Java source code but that's a leaky
abstraction.
On Apr 30, 10:57 am, Ken We
On Apr 30, 8:16 pm, Nathan Sorenson wrote:
> Yes but the contract of subvec is that it returns a "persistent
> vector" and the resulting data structure returns "true" under the
> "vector?" predicate. I know that subvec returns a different type
> because I've looked at the Java source code but th