Re: Addition of new a priori distinct element to a vector

2011-09-23 Thread Alan Malloy
On Sep 23, 3:02 pm, F Lengyel wrote: > On Sep 23, 2:20 am, Kevin Livingston > > wrote: > > what's the actual use case where you want this? > > it seems pretty weird just on it's own.  it may in practice be more > > clever than other solutions, but that's not clear yet.  if you just > > want a uni

Re: Addition of new a priori distinct element to a vector

2011-09-23 Thread F Lengyel
On Sep 23, 2:20 am, Kevin Livingston wrote: > what's the actual use case where you want this? > it seems pretty weird just on it's own.  it may in practice be more > clever than other solutions, but that's not clear yet.  if you just > want a unique symbol there's (gensym) For the sake of illus

Re: Addition of new a priori distinct element to a vector

2011-09-23 Thread Stefan Kamphausen
Hi, is there any particular reason not to use a Set instead of a vector? It solves the issue of distinct values. Or am I missing something? Regards, Stefan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cloju

Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread F Lengyel
On Sep 23, 2:18 am, Andy Fingerhut wrote: > To be very precise, (conj v new-elem) is O(log n) in time and space, but it > is "constant-ish" because the base of the logarithm is something like 32, > rather than something like 2, so the constant factor multiplying the log n > is typically pretty s

Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread Kevin Livingston
what's the actual use case where you want this? it seems pretty weird just on it's own. it may in practice be more clever than other solutions, but that's not clear yet. if you just want a unique symbol there's (gensym) regarding vectors, I found this a helpful read a while back, it's a few yea

Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread Andy Fingerhut
To be very precise, (conj v new-elem) is O(log n) in time and space, but it is "constant-ish" because the base of the logarithm is something like 32, rather than something like 2, so the constant factor multiplying the log n is typically pretty small. Also, there is no difference in Clojure's beha

Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread F Lengyel
On Sep 23, 1:39 am, Nathan Sorenson wrote: > Just to clarify, you want to conj a vector to itself? i.e. [1 2 3 4] --> [1 > 2 3 4 [1 2 3 4]] I'm curious what the application of this is. > > Regarding the overhead of conj-ing to a vector: Clojure's data structures > make use of structural sharing s

Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread Nathan Sorenson
Just to clarify, you want to conj a vector to itself? i.e. [1 2 3 4] --> [1 2 3 4 [1 2 3 4]] I'm curious what the application of this is. Regarding the overhead of conj-ing to a vector: Clojure's data structures make use of structural sharing so conjoining an element to the end of a vector won'

Addition of new a priori distinct element to a vector

2011-09-22 Thread F Lengyel
Suppose I have a vector v. I would like to add a new element to v distinct from all of the elements of v, with the constraint that I assume nothing about v other than it is a vector. (There are cases where it is useful to do this with some algorithms involving reduce, for example.) One way to do