There is an easy solution to your problem...Just hange the fn definition
slightly. For example I am regularly using this:
(defn un-capitalize [^String s]
(let [Cfirst (subs s 0 1)
Crest (subs s 1) ]
(str (.toLowerCase Cfirst) Crest)))
It is pretty obvious what you need to do to convert the above to
"capitalize" which only capitalises the 1st charater...
I agree that with regards to 'least astonishment' the core fn should
capitalize all characters. This is what I'd expect from a fn called
'capitalize'.
Jim
On 12/12/12 14:12, Pierre Allix wrote:
Hello,
The clojure.string/capitalize function is defined as follow:
Converts first character of the string to upper-case, all other
characters to lower-case.
I think it does not followprinciple of least astonishment. I would have
expected to convert only the first character. Moreover converting the other
characters make the function almost useless, I for instance had this string to
capitalize:
"if P is true then do W" which is converted into "If p is true then do w". This
is not helpful.
Is there a good reason to convert the other characters? Shouldn't this be doneexplicitly by the user? Would it make sense to change the capitalize function in the next versions?
--
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 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