Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定
#;> (cons (cons 1 2) 3) ((1 . 2) . 3)
当我们尝试
#;> (cons 3 (cons 1 2)) (3 1 . 2)
什么决定了在哪里.使用?这些构造的内存表示是什么?
.
方案实现通常以列表形式打印看起来像列表的东西:
-> (cons 1 (cons 2 '())) '(1 2)
在您的示例中,(cons 3 (cons 1 2))如果不是最后一个,它将是一个列表2。因此,您的实现会尽最大努力将其打印为列表,直到2. 另一个示例不包含任何看起来像列表的部分,因此它只是作为嵌套对打印。
(cons 3 (cons 1 2))
2