test-check

borkdude 2017-11-10T12:50:46.000044Z

How can I get a sequence of random numbers by providing a seed in clojure.test.check?

2017-11-10T12:52:31.000120Z

what sort of numbers?

2017-11-10T12:53:32.000175Z

if you want to just use the raw RNG code it's pretty easy (map random/rand-long (random/split-n (random/make-random seed) 500))

borkdude 2017-11-10T12:53:49.000204Z

thanks

2017-11-10T12:54:23.000465Z

if you are using this for PBT I would probably recommend using generators instead, or would be interested in why you can't

borkdude 2017-11-10T12:55:39.000107Z

I would like to use this for some graphical algorithm which needs random numbers, but I want to make it deterministic

2017-11-10T12:56:16.000001Z

okay cool; yeah if it's not for testing then using the RNG directly is perfectly fine

borkdude 2017-11-10T16:08:48.000457Z

I’m looking for examples online but can’t find it. Is there a way that I can express that I want ints in a range using the generators + a custom seed?

borkdude 2017-11-10T16:09:01.000012Z

or do I have to convert longs to a range myself, which is also possible

2017-11-10T16:13:42.000648Z

the rng only generates raw uniform longs; if your range isn't close to 64 bits, I'd just use mod to get what you want

borkdude 2017-11-10T16:14:34.000287Z

yeah, cool

borkdude 2017-11-10T16:18:03.000131Z

Is there a way to get around the fixed size 500 in (map (comp #(mod % 1000) r/rand-long) (r/split-n (r/make-random 2) 500)) so I can get a lazy sequence of these numbers or do I need to specify this up front always?

borkdude 2017-11-10T16:19:30.000286Z

I guess I can calculate this up front

2017-11-10T16:45:07.000439Z

you can make an infinite lazy seq

2017-11-10T16:45:19.000076Z

there's a private(?) function in generators.cljc that does this

2017-11-10T16:45:24.000284Z

lazy-random-states or something to that effect

borkdude 2017-11-10T16:55:39.000236Z

So this would be it right? (take 2 (map random/rand-long (gen/lazy-random-states (random/make-random 2))))

2017-11-10T16:56:49.000103Z

yep