I'd like to use test.check to generate sorted time series data of the form
[ [timestamp value] [timestamp value] ..]
where the timestamp, value -pairs are in ascending order by the timestamp.
I can easily generate such data in random order with
(gen/tuple timestamp gen/int)
where timestamp
is e.g. (gen/choose 1412664660 1423419720)
How should I go about generating sorted data?
So it came to me while brushing my teeth..
When I asked the question I was thinking "one level too low" about the data I want to generate.
(gen/tuple timestamp gen/int)
generates individual tuples and my attempts of doing(gen/fmap sort .. )
on them didn't work because it just sorted the contents of the tuples. What I need to generate is vectors of those tuples.. andfmap sort
on those of course works: