Sure, here's a possible approach:

user> (gen/sample (gen/fmap (partial apply concat) (gen/list (gen/fmap
#(repeat 3 %) gen/int))))
(()
 ()
 (0 0 0)
 (3 3 3 3 3 3 2 2 2)
 (3 3 3 2 2 2 0 0 0 3 3 3)
 (2 2 2)
 (-4 -4 -4 -6 -6 -6)
 (4 4 4 5 5 5)
 (7 7 7 3 3 3)
 (3 3 3 7 7 7 9 9 9 7 7 7 4 4 4 -4 -4 -4))

Cheers,
Michał


On 14 May 2014 08:50, Maciej Jaśkowski <[email protected]> wrote:
> Hi there,
>
> I would like to create a generator generating a list of ints with each value
> repeated a number of times e.g.
>
> (gen/sample gen-repeater [ 1 1 1 2 2 2 -1 -1 -1 9 9 9])
>
> this
> (gen/sample (gen/bind gen/int (fn [i] (gen/return (take 5 (repeat i))))))
> returns e.g. ((0 0 0 0 0) (-1 -1 -1 -1 -1) (0 0 0 0 0))
> which is of no interest to me :-(
>
> Is that even possible under test.check to have a generator like that?
>
> Best,
> Maciej Jaśkowski
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
  • test.check Maciej Jaśkowski
    • Re: test.check Michał Marczyk

Reply via email to