我想使用test.check生成表单的排序时间序列数据。
[ [timestamp value] [timestamp value] ..]
在时间戳的位置,值-pairs是按时间戳的升序排列的。
我可以很容易地按随机顺序生成这样的数据
(gen/tuple timestamp gen/int),其中timestamp是(gen/choose 1412664660 1423419720)
如何生成已排序的数据?
发布于 2015-02-08 20:17:44
所以当我刷牙的时候.
当我问到这个问题时,我想到的是我想要生成的数据“太低了一个层次”。
(gen/tuple timestamp gen/int)生成单独的元组,我对它们执行(gen/fmap sort .. )的尝试没有奏效,因为它只是对元组的内容进行排序。我需要生成的是这些元组的向量。当然,fmap sort在这些方面也是有效的:
(def entry (gen/tuple timestamp gen/int))
(def timeseries (gen/fmap sort (gen/vector entry)))https://stackoverflow.com/questions/28398036
复制相似问题