test.check

shuffle generator

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Adding a generator that shuffles the output of a given collection generator would be really useful.
Short example:

(gen/sample (gen/shuffle (gen/vector get/nat))) ;=> ([5 2 4] [9 1 7 8] ...)

This could be used to add a generator for permutations of integers 1,2,...,n which I also missed several times already.

Activity

Hide
Reid Draper added a comment -

Yeah this would be cool. Should it shrink toward the original collection-ordering?

Show
Reid Draper added a comment - Yeah this would be cool. Should it shrink toward the original collection-ordering?
Hide
Gunnar Völkel added a comment - - edited

Yes, that was the idea when we talked about that topic on #clojure. Otherwise, you can just use gen/int to create a seed and use java.util.Random together with java.util.Collections/shuffle.

Show
Gunnar Völkel added a comment - - edited Yes, that was the idea when we talked about that topic on #clojure. Otherwise, you can just use gen/int to create a seed and use java.util.Random together with java.util.Collections/shuffle.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: