Hi clojure folk,
I'm reading up on clojure from the book 'Programming clojure'. In
chapter 2 there is a statement -
"The imperative indexOfAny must deal with several special cases:
null or empty strings, a null or empty set of search characters,
and the absence of a match. These special cases add branches
and exits to the method. With a functional approach, most of these
kinds of special cases just work without any explicit code."
I'm not quite sure if I understand this properly. How is it that with
a functional approach, most of these special cases like null checks or
empty checks get handled automatically? I mean isn't that a property
of the language / api rather than the programming approach per se?
Please explain with some examples!
On a similar note, following is the definition of the function index-
filter given in the book :-
(defn index-filter [pred coll]
(when pred
(for [[idx elt] (indexed coll) :when (pred elt)] idx)))
Why is the 'when pred' check necessary?
Thanks!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en