Re: Fastest way to generate comma-separated list

2013-04-03 Thread Max Penet
I am curious, what data store are you interacting with? On Wednesday, April 3, 2013 2:01:33 PM UTC+2, Ryan wrote: > > Most SQL Database support array types natively > > > If you are using MySQL unfortunately there isn't and the OP (including > myself) probably needs this because his RDBMS does n

Re: Fastest way to generate comma-separated list

2013-04-03 Thread Ryan
> > Most SQL Database support array types natively If you are using MySQL unfortunately there isn't and the OP (including myself) probably needs this because his RDBMS does not support the array type. On Wednesday, April 3, 2013 2:47:45 PM UTC+3, Thomas Heller wrote: > > My Question would be

Re: Fastest way to generate comma-separated list

2013-04-03 Thread Thomas Heller
My Question would be: why are you trying to do this? You mentioned you are working with a database, I assume that means SQL (as almost all NoSQL Databases support some kind of JSON which doesnt require your "workarround"). Most SQL Database support array types natively, while support might be a

Re: Fastest way to generate comma-separated list

2013-04-02 Thread Max Penet
> (comma-separated (list "1" "2" "3" "4" "5")) ==> "\"1\", \"2\", \"3\", \"4\", \"5 > It must work with any data type - ints, strings, other lists, etc. The OP needs different encoding rules per type (some of which are unspecified, strings must be quoted, "etc."), and this could possibly be

Re: Fastest way to generate comma-separated list

2013-04-02 Thread Ryan
Not sure if the OP will see this thread because I was the one that dig it up since I had a similar problem :) user=> (apply pr-str (interpose \, (list "jim" "jon" "chris"))) > "\"jim\" \\, \"jon\" \\, \"chris\"" I am not sure if that's correct. I think that the final string should look like th

Re: Fastest way to generate comma-separated list

2013-04-02 Thread Jim - FooBar();
I'm sorry, I've not followed this discussion - what is wrong with user=>(apply str (interpose \, (list 1 2 3 4 5))) "1,2,3,4,5" the problem is strings where you want to preserve each string...you can special case that and avoid the (apply str...) bit.. user=> (interpose \, (list "jim" "jon" "c

Re: Fastest way to generate comma-separated list

2013-04-02 Thread Max Penet
Using a protocol fn to do the encoding of the values according to the rules you set per type then using clj.string/join should be quite fast and not so horrible. On Thursday, October 28, 2010 2:18:08 AM UTC+2, andrei wrote: > > Hi all, > > I work with a database and need a function, that will

Re: Fastest way to generate comma-separated list

2013-04-02 Thread Ryan
andrei, can you please share the solution you came up after all? On Thursday, October 28, 2010 3:04:32 PM UTC+3, andrei wrote: > > > > Are you looking for pr-str? > > > > user> (pr-str "foo") > > "\"foo\"" > > Yeah, that's exactly what I tried to implement with my `pr-to-str`, > thank you. -

Re: Fastest way to generate comma-separated list

2013-04-02 Thread Ryan
andrei, can you please the solution you came up after all? On Thursday, October 28, 2010 3:04:32 PM UTC+3, andrei wrote: > > > > Are you looking for pr-str? > > > > user> (pr-str "foo") > > "\"foo\"" > > Yeah, that's exactly what I tried to implement with my `pr-to-str`, > thank you. -- --

Re: Fastest way to generate comma-separated list

2010-10-28 Thread andrei
> Are you looking for pr-str? > > user> (pr-str "foo") > "\"foo\"" Yeah, that's exactly what I tried to implement with my `pr-to-str`, thank you. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegrou

Re: Fastest way to generate comma-separated list

2010-10-28 Thread andrei
> Does this help? > > user> (use 'clojure.string) > nil > user> (join "," (range 10)) > "0,1,2,3,4,5,6,7,8,9" It still doesn't work for the list of strings. But thanks for reminding about it. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: Fastest way to generate comma-separated list

2010-10-27 Thread Avram
Does this help? user> (use 'clojure.string) nil user> (join "," (range 10)) "0,1,2,3,4,5,6,7,8,9" -Avram On Oct 28, 4:22 am, andrei wrote: > I was seeking `interpose` function, thanks. But it still doesn't work > for strings - they are not wrapped by "\"\. E.g. > > (apply str (interpose ", "

Re: Fastest way to generate comma-separated list

2010-10-27 Thread Stuart Campbell
On 28 October 2010 13:22, andrei wrote: > > I was seeking `interpose` function, thanks. But it still doesn't work > for strings - they are not wrapped by "\"\. E.g. > > (apply str (interpose ", " (list 1 2 3 4 5))) ==> "1, 2, 3, 4, 5" > > and > > (apply str (interpose ", " (list "1" "2" "3" "4"

Re: Fastest way to generate comma-separated list

2010-10-27 Thread andrei
I was seeking `interpose` function, thanks. But it still doesn't work for strings - they are not wrapped by "\"\. E.g. (apply str (interpose ", " (list 1 2 3 4 5))) ==> "1, 2, 3, 4, 5" and (apply str (interpose ", " (list "1" "2" "3" "4" "5"))) ==> "1, 2, 3, 4, 5" The problem is that applying

Re: Fastest way to generate comma-separated list

2010-10-27 Thread Christopher Petrilli
I didn't do any timing, but, I would say the idiomatic way: (apply str (interpose ", " some-vector)) Chris On Wed, Oct 27, 2010 at 8:18 PM, andrei wrote: > Hi all, > > I work with a database and need a function, that will convert Clojure > sequence to a string with a comma-separated element