gpt4 book ai didi

syntax - # 在 Scheme 数字文字中的含义

转载 作者:行者123 更新时间:2023-12-04 01:40:11 24 4
gpt4 key购买 nike

运行 R5RS 的 DrRacket 说 1###是一个完全有效的 Scheme 编号并打印值 1000.0 .这让我相信英镑符号 (#) 表示数字不准确,但我不确定。规范还说它是数字文字的有效语法,但没有说明这些符号的含义。

关于Scheme 数字文字中# 符号的含义有什么想法吗?

最佳答案

散列语法是在 1989 年引入的。在 Scheme 的作者邮件列表上有一个关于不精确数字的讨论,其中包含了几个不错的想法。有些人捕获了,有些没有。

http://groups.csail.mit.edu/mac/ftpdir/scheme-mail/HTML/rrrs-1989/msg00178.html

一个被卡住的想法是引入 #代表一个未知的数字。
如果您有两位有效数字的测量值,您可以用 23## 表示。数字23是已知的,但最后一位数字是未知的。如果你写 2300 ,那么你就看不出这两个零是不可信的。当我看到我期望的语法时 23##评估为 2350,但(我相信)解释取决于实现。多实现解释23##作为 2300。

这里正式介绍了语法:

http://groups.csail.mit.edu/mac/ftpdir/scheme-mail/HTML/rrrs-1989/msg00324.html

编辑

来自 http://groups.csail.mit.edu/mac/ftpdir/scheme-reports/r3rs-html/r3rs_8.html#SEC52

An attempt to produce more digits than are available in the internal machine representation of a number will be marked with a "#" filling the extra digits. This is not a statement that the implementation knows or keeps track of the significance of a number, just that the machine will flag attempts to produce 20 digits of a number that has only 15 digits of machine representation:

3.14158265358979##### ; (flo 20 (exactness s))



编辑2

Gerald Jay Sussman 写了为什么在此处引入语法:

http://groups.csail.mit.edu/mac/ftpdir/scheme-mail/HTML/rrrs-1994/msg00096.html

关于syntax - # 在 Scheme 数字文字中的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10935110/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com