Re: first element after an element in the sorted-set?
On 24 May 2011 08:07, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, is there a function to find the first element after an element in the sorted-set? (first-element-after 3 (sorted-set 1 2 3 4 5 6)) should return 4? How about this?: (first (drop-while (partial = 3) (sorted-set 1 2 3 4 5 6))) -- Michael Wood esiot...@gmail.com -- 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
Re: first element after an element in the sorted-set?
that may be inefficient for a large-set..? I was hoping it would be log(n).. On Tue, May 24, 2011 at 11:45 AM, Michael Wood esiot...@gmail.com wrote: On 24 May 2011 08:07, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, is there a function to find the first element after an element in the sorted-set? (first-element-after 3 (sorted-set 1 2 3 4 5 6)) should return 4? How about this?: (first (drop-while (partial = 3) (sorted-set 1 2 3 4 5 6))) -- Michael Wood esiot...@gmail.com -- 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
Re: first element after an element in the sorted-set?
finger-trees would have solved the problem .. but unfortunately it is not part of the clojure distro yet.. :( On Tue, May 24, 2011 at 11:53 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: that may be inefficient for a large-set..? I was hoping it would be log(n).. On Tue, May 24, 2011 at 11:45 AM, Michael Wood esiot...@gmail.com wrote: On 24 May 2011 08:07, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, is there a function to find the first element after an element in the sorted-set? (first-element-after 3 (sorted-set 1 2 3 4 5 6)) should return 4? How about this?: (first (drop-while (partial = 3) (sorted-set 1 2 3 4 5 6))) -- Michael Wood esiot...@gmail.com -- 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
Aw: Re: first element after an element in the sorted-set?
Hi, maybe subseq to the rescue? user= (first (subseq (sorted-set 1 2 3 4 5 6) 3)) 4 I'm not sure about the perfomance, but I'd think it's fast? Sincerely Meikel -- 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
Re: Re: first element after an element in the sorted-set?
thanks Meikel.. what you suggested might be it.. Sunil. On Tue, May 24, 2011 at 1:48 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, maybe subseq to the rescue? user= (first (subseq (sorted-set 1 2 3 4 5 6) 3)) 4 I'm not sure about the perfomance, but I'd think it's fast? Sincerely Meikel -- 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
Re: first element after an element in the sorted-set?
Yes, subseq is fast. On May 24, 1:18 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, maybe subseq to the rescue? user= (first (subseq (sorted-set 1 2 3 4 5 6) 3)) 4 I'm not sure about the perfomance, but I'd think it's fast? Sincerely Meikel -- 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
Re: Re: first element after an element in the sorted-set?
On Tue, May 24, 2011 at 4:18 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, maybe subseq to the rescue? user= (first (subseq (sorted-set 1 2 3 4 5 6) 3)) 4 I'm not sure about the perfomance, but I'd think it's fast? Yes, this is right. Note you can also walk the other direction using rsubseq: (first (rsubseq (sorted-set 1 2 3 4 5 6) 3)) ;= 2 --Chouser http://joyofclojure.com/ -- 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