Here's my take on it (all caveats apply, e.g. performance):

(defn indices-of
  "Returns the indices of the given char in the string (0 based)."
  [c string]
  (map second (filter #(= c (first %)) (partition 2 (interleave string
(iterate inc 0))))))

(indices-of \a "abba") ; (0 3)

and hence last-index-of becomes:

(def last-index-of (comp last indices-of))
(last-index-of \a "abbaa") ; 4

U

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