在 SML 中生成随机数

问题描述:

如何从特定范围生成随机数,例如范围 [1, 100] 中的整数 34?

How can you generate a random number from a specific range, for example the integer 34 in the range [1, 100]?

我查看了 随机结构 但它没有不要给我我想要的,至少从我能理解的角度来看.

I looked at the Random structure but it doesn't give me what I want, at least from what I can understand.

我认为你必须像这样在给定的链接中使用 Random 结构......

I think you have to use the Random structure in the given link like this ...

- val nextInt = Random.randRange (1,100);
- val r = Random.rand (1,1);
- val x1 = nextInt r;
- val x2 = nextInt r;