Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns test.core
- (:require [clojure.spec :as s]
- [clojure.spec.test :as stest]
- [clojure.test.check.generators :as gen]))
- (s/def ::file-count nat-int?)
- (s/def ::operations (s/map-of keyword? pos-int?))
- (s/def ::time-total (s/and double? (complement neg?)))
- (s/def ::summary-res
- (s/keys :req-un [::file-count
- ::operations
- ::time-total]))
- (s/fdef combine-summaries
- :args (s/cat :xs (s/coll-of ::summary-res :min-count 1))
- :ret ::summary-res)
- (defn combine-summaries
- [summaries]
- (letfn [(deep-merge [a b]
- (merge-with (fn [x y]
- (if (map? y)
- (deep-merge x y)
- (+ x y)))
- a b))]
- (reduce deep-merge summaries)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement