Or: (defn sv [vector value] (let [i (.indexOf ^java.util.List vector value)] (if (neg? i) [] (subvec vector i))))
On Sat, May 14, 2011 at 7:50 PM, Jonathan Fischer Friberg < odysso...@gmail.com> wrote: > I think this should be pretty fast > https://gist.github.com/972423 > > It is at least faster than using split-with: > > (time (dotimes [_ 1e6] (last (split-with (partial not= 'x) '[a b c x d > f])))) > => "Elapsed time: 521.288318 msecs" > > (time (dotimes [_ 1e6] (subvec-at-val 'x '[a b c x d f]))) > => "Elapsed time: 315.532724 msecs" > > Jonathan > > > On Sat, May 14, 2011 at 7:32 PM, Base <basselh...@gmail.com> wrote: > >> Hi All- >> >> I am sure I am just missing this in contrib somewhere , but.... >> >> I am trying to find a subvector such that it returns the rest of the >> vector at the first occurrence of a value >> >> (def v ['a 'b 'c 'd 'e 'f 'g]) >> >> (my-fun 'c v) >> => ['c 'd 'e 'f 'g] >> >> I need this to be *really* efficient (who doesn't, right) >> Sort of looping through this, what is the best way? >> >> thanks >> >> base >> >> -- >> 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 > > > -- > 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 > -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.cgrand.net/ (en) -- 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