Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-10-01 Thread Michael Gardner
On Sep 30, 2010, at 10:37 PM, HiHeelHottie wrote: (ns test-test.parse (:use [clojure.contrib.string :only (split)])) (defn parse-char [m c] (condp = (:state m) :degree (cond (Character/isDigit c) (assoc m :degree (+ (* (:degree m) 10) (Character/digit c 10)))

Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-30 Thread Steven E. Harris
Mark Engelberg mark.engelb...@gmail.com writes: str uses a string builder behind the scenes, so it's efficient this way. If the `str' implementation didn't take the input sequence to be lazy, it could figure out how long the resulting string needed to be, and construct the StringBuilder using

Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-29 Thread HiHeelHottie
Is there an idiomatic way to build up a string over different lines of code? Or, should one simply use StringBuilder. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from

Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-29 Thread Stuart Campbell
On 30 September 2010 12:48, HiHeelHottie hiheelhot...@gmail.com wrote: Is there an idiomatic way to build up a string over different lines of code? Or, should one simply use StringBuilder. I would just use (str) - it uses a StringBuilder when given more than one argument: user (source str)

Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-29 Thread Michael Gardner
On Sep 29, 2010, at 10:32 PM, Stuart Campbell wrote: I would just use (str) - it uses a StringBuilder when given more than one argument: There's also (format), which I find helpful for building more complex strings. -- You received this message because you are subscribed to the Google

Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-29 Thread HiHeelHottie
Thanks for the response. What if you are appending over different lines of code? Would it be slightly more efficient to use one StringBuilder or not worth the bother. On Sep 29, 11:32 pm, Stuart Campbell stu...@harto.org wrote: On 30 September 2010 12:48, HiHeelHottie hiheelhot...@gmail.com

Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-29 Thread Michael Gardner
On Sep 29, 2010, at 11:01 PM, HiHeelHottie wrote: What if you are appending over different lines of code? Could you give an example of what you're trying to do? Mutable strings are almost never necessary, in my experience. -- You received this message because you are subscribed to the Google

Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-29 Thread Mark Engelberg
Start with an empty vector, say v. conj your strings to the vector at the various points in your code, so at the end v will be something like [this is a string] Then, when you're done, apply str to the vector, i.e., (apply str v) to get thisisastring str uses a string builder behind the scenes,

Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-29 Thread Sean Corfield
On Wed, Sep 29, 2010 at 9:01 PM, HiHeelHottie hiheelhot...@gmail.com wrote: Thanks for the response.  What if you are appending over different lines of code?  Would it be slightly more efficient to use one StringBuilder or not worth the bother. I'm trying to think what your code would look

Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-29 Thread B Smith-Mannschott
On Thu, Sep 30, 2010 at 04:48, HiHeelHottie hiheelhot...@gmail.com wrote: Is there an idiomatic way to build up a string over different lines of code? Or, should one simply use StringBuilder. I recently wrote a program that generates complex java enums (as source) from input data recorded