Re: Need suggestions on how to write rand-interleave test.check generator.

2015-08-16 Thread Mayank Jain
Interesting idea. Will look into how shuffle works and see if I can adapt that instead. Thanks :) On Sat, Aug 15, 2015 at 7:56 AM, Gary Fredericks wrote: > Another kind of approach that would be worth trying is adapting > test.check's own shuffle generator >

Re: Need suggestions on how to write rand-interleave test.check generator.

2015-08-14 Thread Gary Fredericks
Another kind of approach that would be worth trying is adapting test.check's own shuffle generator . It generates a sequence of pairs of indexes and t

Re: Need suggestions on how to write rand-interleave test.check generator.

2015-08-14 Thread Mayank Jain
Oh okay. So if a value given to gen/return function is coming via a generator will shrink because that generator will shrink. But say (gen/return [1 2 3 4]) will never shrink because it is saying just return it as it is and never shrink this. Got it! :) On Fri, Aug 14, 2015 at 10:34 PM, Carlo Zanc

Re: Need suggestions on how to write rand-interleave test.check generator.

2015-08-14 Thread Carlo Zancanaro
What it means is that the value returned by gen/return can't be shrunk. Shrinking is done by constructing a (lazily evaluated) tree of "smaller" forms of the same thing. So a number, let's say 4, contains a tree of smaller numbers (0, 1, 2, and 3) which specify how to shrink it. (The tree is const

Re: Need suggestions on how to write rand-interleave test.check generator.

2015-08-14 Thread Mayank Jain
Ah right! I knew I had to use gen/choose for this, I am still grokking bind :) Thanks for your help! That indeed did the trick for me :) One thing I am clear about is, If I use gen/return it says it'll not shrink. Does that mean when a test fails for a certain order, it won't try to shrink that o

Re: Need suggestions on how to write rand-interleave test.check generator.

2015-08-14 Thread Carlo Zancanaro
Hey Mayank! Similarly to your attempt last time, you need to use gen/bind to get the result of a generator which you can then use to make a new generator. (defn- rand-interleave* [coll acc] (if (seq coll) (gen/bind (gen/choose 0 (dec (count coll))) (fn [index]

Need suggestions on how to write rand-interleave test.check generator.

2015-08-14 Thread Mayank Jain
Hi Everyone, Here's the problem I am facing, I need to write a generator which takes any number of sequences, interleaves them but maintains the order within each sequence. Assume each sequence has at least one element. For example: (rand-interleave [1 2 3 4] [:a :b] [:A :B :C :D :E]) > => [:a 1