My solution is very wrong, sorry for that.

I am just wondering, cant we use memfn to make lastIndexOf as a first
class function here?

areduce can be used too.

(defn last-indexof [cs c]
  (areduce cs i lst-idx -1
    (if (= c (aget cs i)) i lst-idx)))

(-> "aabbccd" to-array (last-indexof \c))

Regards.
Jestan Nirojan

On Nov 12, 12:07 pm, Jestan Nirojan <jestanniro...@gmail.com> wrote:
> I think regex free solution is best for this
>
> (defn last-indexof [s c]
>    (->> s (filter #(= c %)) count dec)
>
> On Nov 12, 3:36 am, "jongwon.choi" <oz.jongwon.c...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi
>
> > I'm wondering the best way to express:
>
> >      (position #\a "abba" :from-end t)
>
> > Should I use interop?
>
> >      (.lastIndexOf "abba" (int \a))
>
> > Thanks!

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