-
-
Save amalloy/1214703 to your computer and use it in GitHub Desktop.
rate-filter.clj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn remove-out-of-range-rates [rates min-rate max-rate] | |
(let [out-of-range? #(not (<= min-rate (:total_rate %) max-rate))] | |
(for [{r :rates :as item} rates | |
:let [allowed (remove out-of-range? r)] | |
:when (seq allowed)] | |
(assoc item :rates allowed)))) | |
(remove-out-of-range-rates [{:rates [{:total_rate 10} {:total_rate 15}]} | |
{:rates [{:total_rate 12} {:total_rate 9}]}] | |
10 15) | |
;; => | |
;; [{:rates ({:total_rate 10} {:total_rate 15})} {:rates ({:total_rate 12})}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment