Kowal 发表于 2022-7-5 17:58:46

Lee-Mac随机数函数

尊敬的李:,
你的代码很棒。
但对于负偏移的间隔,周期为1。
(LM:randrange 1 3)
1
1
1
2
1
3
3
1
2
3
 
(LM:randrange -3 -1)
-1
-2
-1
-2
0
0
0
-2
0
-1
 
当然,我可以用一系列积极和消极的方式来改变他。我也可以改变负片上的符号。
请解释一下。

Lee Mac 发表于 2022-7-5 18:15:13

请尝试以下[未经测试的]修改:
;; Random in Range-Lee Mac
;; Returns a pseudo-random integral number in a given range (inclusive)

(defun LM:randrange ( a b )
   (+ (min a b) (fix (* (LM:rand) (1+ (abs (- a b))))))
)
 
编辑:已更新。

Lee Mac 发表于 2022-7-5 18:30:26

我现在还更新了我网站上的函数:Random in Range

Kowal 发表于 2022-7-5 18:54:00

谢谢你的更新。
对不起,我的英语很差。

Lee Mac 发表于 2022-7-5 19:03:01

不客气,科瓦尔,没有必要道歉。
页: [1]
查看完整版本: Lee-Mac随机数函数