Why doesn't repeatedly generate reproducible random numbers when using a seed in Clojure?

前端 未结 2 1137
死守一世寂寞
死守一世寂寞 2021-01-04 11:07

I have some functions that require a series of random numbers so I\'ve taken some simple primitives such as #(inc (g/uniform 0 n)) and I can\'t seem to generate

2条回答
  •  走了就别回头了
    2021-01-04 11:19

    Because of laziness. You return from binding before the sequence is realized. Therefore, the lazy sequence never sees the bindings you set. One solution would be to force realization with a doall on the sequence inside the binding.

提交回复
热议问题