1. Meikel Brandmeyer
  2. ClojureCheck

Commits

Meikel Brandmeyer  committed 0ccb06b

Elements generator

* combinators.clj (elements): new function

  • Participants
  • Parent commits 7fde3c3
  • Branches default

Comments (0)

Files changed (1)

File src/de/kotka/tap/clojurecheck/combinators.clj

View file
               v     (first (drop-while #(< (first %) guess)
                                        weights-and-gens))]
       v)))
+
+(defn elements
+  "elements returns a generator, which chooses one of the given values."
+  [& elems]
+  (let [len (dec (count elems))]
+    (let-gen [l [Integer 0 len]]
+      (nth elems l))))