Permalink
Browse files

More explanation.

  • Loading branch information...
1 parent f7f03a1 commit 53c8f05167ac05e29da32b9933f17f0e097e81fe @marick committed Dec 18, 2012
Showing with 22 additions and 4 deletions.
  1. +22 −4 sources/higher-order-functions.clj
@@ -1,8 +1,26 @@
-;;; Reversed-digits shows one Clojure feature that is outside the
-;;; scope of this book:
+;;; `reversed-digits` takes advantage of two new facts (that aren't
+;;; used in the rest of the book):
;;;
-;;; 1. Java interoperability allows you to call Java methods---both instance
-;;; methods and class methods. `Integer.` refers to the Integer constructor.
+;;; 1. Java interoperability allows you to call Java methods--both
+;;; instance methods and class methods. So you can call one of
+;;; Java's Integer constructors like this:
+;;;
+;;; user=> (Integer. "321")
+;;; 321
+;;;
+;;; 2. Strings are sequences, so you can apply sequence functions
+;;; to them. The result isn't a string, though, but rather a
+;;; sequence of Java Characters:
+;;;
+;;; user=> (reverse "foo")
+;;; (\o \o \f)
+;;;
+;;; You can convert a character into a string with `str`:
+;;; user=> (str \o)
+;;; "o"
+;;;
+;;; Thanks to Jeremy W. Sherman for a version that improved on my
+;;; original.
(def reversed-digits
(fn [string]

0 comments on commit 53c8f05

Please sign in to comment.