Commits

Meikel Brandmeyer  committed f1cc5cf

Add one-of combinator

  • Participants
  • Parent commits 359f247

Comments (0)

Files changed (1)

File src/main/clojure/clojurecheck/core.clj

                     (some (fn [[c f]] (when (< f dice) c)) choices)))]
     (fn [size]
       ((choose) size))))
+
+(defn one-of
+  "Chooses one of the given generators with equal probability.
+  The size guidance is passed verbatim to the chosen generator."
+  {:added "1.0"}
+  [choices]
+  (frequency (zipmap choices (repeat 1))))