SHARE
TWEET

Untitled

a guest Oct 17th, 2014 217 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn compare-ab [x y]
  2.   (compare [(get x :a) (get x :b)]
  3.            [(get y :a) (get y :b)]))
  4.  
  5. (def ss-ab (apply sorted-set-by compare-ab
  6.                       [{:a 42 :b 5000}
  7.                        {:a 1 :b 2}
  8.                        {:a 99 :b -1000}
  9.                        {:a -1 :b 7}]))
  10. user=> ss-ab
  11. #{{:a -1, :b 7} {:a 1, :b 2} {:a 42, :b 5000} {:a 99, :b -1000}}
  12.  
  13. user=> (subseq ss-ab compare-ab 5)
  14. ({:a -1, :b 7} {:a 1, :b 2} {:a 42, :b 5000} {:a 99, :b -1000})
  15.  
  16. user=> (subseq ss-ab > 5)
  17. ({:a -1, :b 7} {:a 1, :b 2} {:a 42, :b 5000} {:a 99, :b -1000})
  18.  
  19. It's not selecting a subsequence....
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top