Re: Small question: inserting something at the beginning of a vector

2009-06-27 Thread Meikel Brandmeyer
Hi again, Am 27.06.2009 um 11:59 schrieb Meikel Brandmeyer: There is now constructor, like [] or {}. Just use c.l.PersistentQueue/EMPTY. I meant: there is _no_ constructor Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature

Re: Small question: inserting something at the beginning of a vector

2009-06-27 Thread Meikel Brandmeyer
Hi, Am 27.06.2009 um 02:27 schrieb samppi: Mr. Brandmeyer You can call me Meikel, I guess. ;) What might also be interesting if you want to insert at one end and take out at the other is clojure.lang.PersistentQueue. conj will insert at the front and pop/peek will work at the end. There is

Re: Small question: inserting something at the beginning of a vector

2009-06-26 Thread samppi
Thanks for the replies. Mr. Brandmeyer's solution is exactly what I needed; I don't really want to change rep+'s return value from a vector, which would sort of break backwards compatibility. On Jun 26, 8:25 am, Meikel Brandmeyer wrote: > Hi, > > Am 26.06.2009 um 17:09 schrieb samppi: > > > @Mr.

Re: Small question: inserting something at the beginning of a vector

2009-06-26 Thread Stephen C. Gilardi
On Jun 26, 2009, at 11:09 AM, samppi wrote: I'm considering changing rep+'s documentation to state that it will return a "collection" rather than a "vector", and then just use cons without vec. You might also consider describing it as a "seq". If you use "cons", the object returned will be

Re: Small question: inserting something at the beginning of a vector

2009-06-26 Thread Meikel Brandmeyer
Hi, Am 26.06.2009 um 17:09 schrieb samppi: @Mr. Gilardi, this is for a one-time only thing. I have a function, called rep*, that builds up a vector from left to right. Another, separate function, called rep+, calls rep*, but it needs to slip in an element at the vector's beginning. Maybe you

Re: Small question: inserting something at the beginning of a vector

2009-06-26 Thread samppi
Thanks for the replies, everyone. @Mr. Gilardi, this is for a one-time only thing. I have a function, called rep*, that builds up a vector from left to right. Another, separate function, called rep+, calls rep*, but it needs to slip in an element at the vector's beginning. I'm considering changi

Re: Small question: inserting something at the beginning of a vector

2009-06-24 Thread Stephen C. Gilardi
On Jun 24, 2009, at 6:44 PM, arasoft wrote: This also works: (into [-1] [0 1 2 3 4]) but I am more than uncertain whether it is "proper". Generally, the need to insert at the beginning of a vector should trigger some close scrutiny as to whether vector is the right data type to use in thi

Re: Small question: inserting something at the beginning of a vector

2009-06-24 Thread arasoft
This also works: (into [-1] [0 1 2 3 4]) but I am more than uncertain whether it is "proper". On Jun 25, 12:26 am, CuppoJava wrote: > I personally use (concat [-1] [0 1 2 3 4]), but I've never been happy > with that either. I would be interested in the proper way of doing > this also. >   -Patri

Re: Small question: inserting something at the beginning of a vector

2009-06-24 Thread CuppoJava
I personally use (concat [-1] [0 1 2 3 4]), but I've never been happy with that either. I would be interested in the proper way of doing this also. -Patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" g

Small question: inserting something at the beginning of a vector

2009-06-24 Thread samppi
Currently, if I want to do this: (mystery-fn [0 1 2 3 4] -1) -> [-1 0 1 2 3 4]), I use vec and cons: (vec (cons a-vec obj-to-insert)). Is there a better way? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" gr