Hi all,

In Stuart Halloway's book (Programming Clojure) is a wonderful example of 
the succinctness of Clojure where he compares the Apache Commons 
implementation of the isBlank method (
http://commons.apache.org/lang/api-2.5/src-html/org/apache/commons/lang/StringUtils.html#line.227)
 
with a Clojure equivalent which is a single line:

(defn blank? [s] (every? #(Character/isWhitespace %) s))

I have used this example a few times to show colleagues the difference 
between Java and Clojure and why (IMHO) the Clojure solution is so much 
nicer. Earlier today I looked at clojure.string and noticed that it had 
blank? in it and looking at the source (
https://github.com/clojure/clojure/blob/f30995c86056959abca53d0ca35dcb9cfa73e6e6/src/clj/clojure/string.clj#L225)
 
I noticed that the actual implementation in Clojure is surprisingly similar 
to the Java one (verbose, several if's, a loop etc.)

Is there any particular reason for this? It is performance? What is wrong 
with Stuarts example? (I just checked it and it correct as far as I can 
tell).

And a second question: What other examples are people using to demonstrate 
the advantages of Clojure (in an elevator pitch style equivalent)

TIA, 

Thomas

-- 
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

Reply via email to