(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
(defn last-index-of [c string]
(first (seq-utils/find-first (fn [[_ a]] (= a c)) (reverse
(seq-utils/indexed string)))))
P.S. Jong Won, how are you liking Clojure? I've met you in Parramatta
and joined the ADO team :) Nice to have you on the group here :)
Cheers
Andreas
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en