Sean, Sorry man, but I'm not willing to change my personal coding style. It's not a matter of getting used to Clojure. I'm not an expert on it yet, but I've been studying and working with it, for a little over a year. I prefer the indentation; it makes more sense to me.
Your image, though, doesn't reflect my intended indentation style for lisp code. It looks like some reformatting took place. As I agreed with James, if asking for assistance, I'll reformat the code first, to match the standard Clojure style. Similarly, if I'm able to help someone else, I'll do so, in a style they are comfortable with. For my own personal coding, which isn't completely settled yet, - gotta go with my own comfort level. If there are other styles out there, that you know about, I'm willing to take a look at them. Although the traditional lisp style with multiple adjacent parentheses doesn't work for me, there might be other styles worth looking at. Perhaps the upcoming Cursive, when it hits 1.x, will have some kind of custom beautifier, which will make these points moot. Thanks for pointing out the error in the if statement. You're correct. On Sun, Nov 23, 2014 at 5:27 PM, Sean Corfield <s...@corfield.org> wrote: > Dan, I’m with James here. Your code as presented is really hard to read > for folks used to the "standard Clojure style" - the strange layout of > parentheses is very distracting. The use of underscore instead of hyphen is > also a bit jarring. > > I’m guessing your background is C/C++/Java and you think the standard > Clojure style of formatting looks weird? You’ll get used to it. Especially > if you set your editor up to auto-close / auto-match parentheses for you > and use some sort of "rainbow parentheses" setting (so matching parens are > the same color, and each matched pair is different to its neighbor). > > (defn simplify > "Replace expression with simplified expressions, using > {s-substring s-replace-character} map of replacements" > [s-expr map-translations] > (if (= (count s-expr) 1) > s-expr > (let [next-expr (reduce-kv clojure.string/replace s-expr > map-translations)] > (if (< (count next-expr)) > (count s-expr)) > (recur next-expr map-translations)))) > > Here's how that looks in my editor: > > > https://www.dropbox.com/s/fwyrn0k9vbtljs2/Screenshot%202014-11-23%2014.19.22.png?dl=0 > > I think your < test is incorrect (now that I can clearly see the code): (< > (count next-expr)) is always true and then you’re throwing away the value > of the `if` (either (count s-expr) or nil since you have no > then-expression). Did you mean this, perhaps? > > (if (< (count s-expr) (count next-expr)) > s-expr > (recur next-expr map-translations)) > > Sean > > On Nov 23, 2014, at 12:45 PM, James Reeves <ja...@booleanknot.com> wrote: > > I'd strongly suggest following standard Clojure formatting, otherwise > you're going to run into problems. If you use your own custom formatting > that only you can read easily, then people are going to find it very > difficult to help or collaborate with you. Deliberately putting up barriers > to communication is a strong incentive for people to pass over your posts - > why should they have to reformat your code just to understand it? > > - James > > On 23 November 2014 at 20:05, Dan Campbell <dcwhat...@gmail.com> wrote: > > Yep, sure enough, works like a gem, thanks. I had originally tried > reduce, but wasn't able to get it to work, in this context. reduce-kv > would have saved a lot of time, on previous code. > > > Sorry about the formatting, James. I structure my code differently than > the standard Clojure format, and some of the tab sizes (2 or 3 spaces) got > lost in the copying & pasting. Here's my final version, which works for > several input strings: > > ; Credit to James Reeves > (defn simplify > "Replace expression with simplified expressions, using > { s_substring, s_replace-character } map of replacements > " > [ s_expr map_translations ] > (if (= (count s_expr) 1) > s_expr > ( > let > [ next-expr ( reduce-kv clojure.string/replace s_expr > map_translations )] > (if ( < (count next-expr) ) > (count s_expr) > ) > (recur next-expr map_translations ) > ) ; else let > ) ; if (= (count s_expr) 1) > ) > > > > -- > 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 new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to a topic in the > Google Groups "Clojure" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/clojure/GFOXhZKooyI/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.