如何将代码 `cons[A;B]` 放入 repl,运行 它,并查看输出 `(A.B)`?

How do I put the code `cons[A;B]` in a repl, run it, and see the output `(A . B)`?

我找到了一个 LISP 1.5 Manual,里面有一些代码。

这个来自第 1.2 节

Examples

    cons[A;B]=(A . B)

通过阅读手册,函数 cons 似乎将两个原子作为输入参数,AB,并输出一个 S 表达式,(A . B).

问题:

如何将代码 cons[A;B] 放入 repl,运行 并查看输出 (A . B)?

我希望做如下事情:

~ $ lisp1.5
> cons[A;B]
=> (A . B)

例如,如果我去 https://www.ruby-lang.org/en/ 看到一些代码,我会复制它,在我的 shell 中输入 irb 并粘贴它。

~ $ irb
irb(main):001:0> puts "Hello World!"
Hello World!
=> nil

手册1.2节说明这只是一个符号,用来帮助读者区分函数和S-expressions(重点是我的)

We shall introduce some elementary functions of S-expressions. To distinguish the functions from the S-expressions themselves, we shall write function names in I lower case letters, since atomic symbols consist of only upper case letters. Furthermore, the arguments of functions will be grouped in square brackets rather than parentheses. As a separator or punctuation mark we shall use the semicolon.

后面有例子:

cons[A ; B] = (A . B)

手册介绍了Lisp、其评估模型、编译器等。 以上是cons的数学定义,其中AB是元变量:对于所有值AB,应用consAB 上是 cons-cell,其中 CAR 部分是 A,CDR 部分是 B。如果有人开发了指称语义来表达 Ruby 的评估模型,您将拥有相同类型的定义。如果你愿意,你可以转换这个符号,即你写 (cons 1 2) 来具体测试它。但是 1.5 手册可以说不是学习自 1994 年以来标准化的 Common Lisp 的最佳起点。您可以尝试以下手册:

请参考 Cliki,Common Lisp wiki。