为什么在PLT-Scheme 372中'(a.b.c)评估为(bac)? [英] Why does '(a . b . c) evaluate to (b a c) in PLT-Scheme 372?
问题描述
我试图了解对,缺点,点分元组和正确列表之间的关系PLT-方案372.我的问题的详细上下文如下:
I'm trying to understand the relations between pair, cons, dotted tuples and proper list in PLT-Scheme 372. The detailed context of my question is as follows:
在阅读了一些教科书并进行反复试验后,我得到了以下理解和直观的想法(我可能是错的...):
After reading some textbook and doing trial-and-error, I have got the following understanding and intuitive ideas (I may be wrong...):
-
所有列表都是成对的,例如:
all lists are pairs, e.g.:
(pair? (list 'a 'b 'c)) => #t
所有优点都是成对的,例如:
all conses are pairs, e.g.:
(pair? (cons 'a (cons 'b 'c))) => #t
一些点分隔的元组是成对的,例如:
some dot-separated tuples are pairs, e.g.:
(pair? '(a . b)) => #t
(pair? '(a . b . c)) => #t
在标准R5RS中,这不是合法语法.
然后我碰到了这个问题:为什么'(a.b.c)求和(b a c)?在哪里可以找到点的完整使用手册?
Then I bumped into this problem: Why does '(a . b . c) evaluate to (b a c)? Where can I find a complete usage manual of dot?
'(a . b) => (a . b)
'(a . b . c) => (b a c)
'(a . b . c . d) => illegal use of `.'
'(cons 'a (cons 'b 'c)) => (a b . c)
推荐答案
对于球拍(PLT),有一个很好的描述此处.
For Racket (PLT), there is a good description here.
关于语法(a . b . c)
,请参见页面底部,它是特定于球拍的阅读器扩展,旨在将诸如(< 1 2)
的典型测试表示为(1 . < . 2)
.
Regarding the syntax (a . b . c)
look at the bottom of the page, it's a Racket-specific reader extension designed to express typical tests like (< 1 2)
as (1 . < . 2)
.
这篇关于为什么在PLT-Scheme 372中'(a.b.c)评估为(bac)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!