如何在 DrScheme R5RS 中使用 "random" 函数
How to Use "random" function in DrScheme R5RS
我想在 DrScheme R5Rs 中使用 "random" 函数,但它说它不存在。但是可以在"Advanced student"中使用,我需要在R5RS中使用,请问有什么方法吗?
提前致谢!
注意:DrScheme 非常古老。您或许应该升级到支持的 DrRacket.
版本
R6RS有随机数通过SRFI-27: Sources of Random Bits.
#!r6rs
(import (rnrs)
(srfi :27))
(random-integer 10) ; ==> 9
对于某些实现,R5RS 仍然可以使用 SRFI-27,但它不是完全可移植的。在球拍下,可以在 R5RS 模式下执行此操作:
#!r5rs
(#%require srfi/27) ; non portable way to include library
(random-integer 10) ; ==> 9
您还可以包括以球拍语言提供的程序,但那样可移植性稍差:
#!r5rs
(#%require (only racket/base random)) ; non portable way to include non portable library procedure
(random 10) ; ==> 9
我想在 DrScheme R5Rs 中使用 "random" 函数,但它说它不存在。但是可以在"Advanced student"中使用,我需要在R5RS中使用,请问有什么方法吗? 提前致谢!
注意:DrScheme 非常古老。您或许应该升级到支持的 DrRacket.
版本R6RS有随机数通过SRFI-27: Sources of Random Bits.
#!r6rs
(import (rnrs)
(srfi :27))
(random-integer 10) ; ==> 9
对于某些实现,R5RS 仍然可以使用 SRFI-27,但它不是完全可移植的。在球拍下,可以在 R5RS 模式下执行此操作:
#!r5rs
(#%require srfi/27) ; non portable way to include library
(random-integer 10) ; ==> 9
您还可以包括以球拍语言提供的程序,但那样可移植性稍差:
#!r5rs
(#%require (only racket/base random)) ; non portable way to include non portable library procedure
(random 10) ; ==> 9