如何将表单20.2的值转换为(random ...)接受的值?
我试过这些:
;; x defined by some earlier maths and of form 20.2
(random (round x))
(random (floor x))但两人都回来了:
random: contract violation
expected: (or/c (integer-in 1 4294967087) pseudo-random-generator?)
given: 20.0发布于 2016-02-13 14:39:38
这些方法也有效,根据文档,它们只是您的方法的缩写:
(random (exact-round x))
(random (exact-floor x))发布于 2016-02-13 14:23:31
这篇文章似乎回答了Scheme的问题:http://computer-programming-forum.com/40-scheme/674db7a1706960d5.htm
因此,通过这样的代码,我得到了我想要的结果:
(random (inexact->exact (round x)))
(random (inexact->exact (floor x)))这是最简单的方法吗?
https://stackoverflow.com/questions/35381053
复制相似问题