Finding the *first* index isn't very Clojurish, what you want is to find *all* the indexes, lazily. Then if you want the first one, just call first.
(use '[clojure.contrib.seq-utils :only (positions)])
(positions #{99} [0 99 3334 53 2 5 99 2 55 63])
-> (1 6)
Cheers,
Stu
> --
> 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
In general, 'some' is used for linear searches. Given a vector 'v':
(some #(and (= 99 (v %)) %) (range 0 (count v)))
This is awkward because you're asking for the index and not the value itself. Index-based array manipulation is not often used in Clojure.