方案中列表的定义
终于尝试学习 Lisp 方言(Scheme),我遇到了列表的两个定义 -
“空列表或 cdr 是列表的对”。
“用括号括起来的 S 表达式的集合”。
这些定义等价吗?
Finally taking the plunge to learn a Lisp dialect (Scheme), I have encountered two definitions of a list -
"Either the empty list or a pair whose cdr is a list".
"A collection of S-Expressions enclosed by parentheses".
Are these definitions equivalent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它们与
{'a','b','c'}
和"abc"
等价,前者是机器对列表的逻辑表示,后者是你在代码中表示它的方式。
在方案中,你几乎可以将所有内容视为一个列表:)(有人会因此而对我投反对票,但当我尝试思考方案式时,我发现这是真的。)
They're as equivalent as
{'a','b','c'}
and"abc"
The former is the machine's logical representation of a list, the latter is how you represent it in your code.
And in scheme, you can pretty much treat everything as a list :) (Someone's going to downvote me for that, but I found it to be true when trying to think scheme-esque.)
我要上演我最喜欢的狗和小马表演了!
(来源:hedgee.com)
这对应于以下:
该图说明了您的第一个语句(空列表对象表示为黑框)。代码片段说明了你的第二个。 :-)
I'm going to bring out my favourite dog-and-pony show!
(source: hedgee.com)
This corresponds to the following:
The diagram illustrates your first statement (the empty-list object is denoted as a black box). The code snippet illustrates your second. :-)