nchubrich wrote:
> I need to make a data structure for a query such as "find everything
> that is priced $3.27 - $6.12" (and perhaps sum up the total revenue
> for all items in that price range). 


That's one of the things sorted maps are for:

(let [objects-by-price (sorted-map 0.50 :cookie, 5.0 :lunch, 

                                    6.10 :movie, 200.0 :tv)] 

   (take-while #(<= (key %) 6.12) (subseq objects-by-price >= 3.27))) 

 

=> ([5.0 :lunch] [6.1 :movie]) 



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