This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-16
Channels
- # beginners (144)
- # boot (40)
- # cljsjs (1)
- # cljsrn (30)
- # clojure (190)
- # clojure-india (1)
- # clojure-poland (7)
- # clojure-russia (13)
- # clojure-spec (2)
- # clojurescript (2)
- # component (23)
- # css (6)
- # emacs (3)
- # events (5)
- # garden (4)
- # hoplon (2)
- # jobs-discuss (2)
- # klipse (1)
- # lein-figwheel (1)
- # off-topic (36)
- # re-frame (28)
- # reagent (2)
- # ring (7)
- # ring-swagger (2)
- # rum (3)
- # test-check (4)
- # untangled (4)
@jfntn one way is using gen/let
:
(defn gen-with-index-and-count-using-let
"Return a generator that will return tuples of:
[<value from coll-gen>
[<valid index in coll>
<count within bounds of index to end of coll>]."
[coll-gen]
(gen/let [coll coll-gen
index (gen/choose 0 (max 0 (dec (count coll))))
bounded-count (gen/choose 0 (- (count coll) index))]
[coll [index bounded-count]]))