1

I found a LISP 1.5 Manual with some code in it.

This one is from Section 1.2

Examples

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

From reading through the manual it looks like the function cons is taking two atoms as input arguments, A and B, and outputting an S-expression, (A . B).

Question:

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

I'm expecting to do something like:

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

For example, if I went to https://www.ruby-lang.org/en/ and saw some code, I would copy it, type irb into my shell and paste it.

enter image description here

~ $ irb
irb(main):001:0> puts "Hello World!"
Hello World!
=> nil
Will Ness
  • 70,110
  • 9
  • 98
  • 181
mbigras
  • 7,664
  • 11
  • 50
  • 111
  • 1
    You mean: `(cons 'A 'B)`? – dsm Mar 03 '18 at 04:26
  • 1
    Note that `cons[A;B]` is written in the so-called Metalanguage, not in Lisp, which is instead written as S-Expressions (like `(cons 'A 'B)`). This is explained later in the manual. So you should get a lisp (Scheme, Common Lisp, etc.) interpreter/compiler and use S-Expressions. – Renzo Mar 03 '18 at 07:16
  • 1
    What you are describing is M-expressions which was a proposed syntax for Lisp which was never implemented. See, for instance [the Wikipedia entry for them](https://en.m.wikipedia.org/wiki/M-expression). –  Mar 03 '18 at 11:53

1 Answers1

2

Section 1.2 of the manual explains that this is only a notation, used to help readers distinguish between functions and S-expressions (emphasis mine).

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.

It is followed by an example:

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

The manual introduces Lisp, its evaluation model, the compiler, etc. The above is the mathematical definition of cons, where A and B are metavariables: for all values A and B, the application of cons on A and B is a cons-cell where the CAR part is A and the CDR part B. If someone developed a denotational semantics to express Ruby's evaluation model, you would have the same kind of definitions. You can convert this notation if you want, i.e. you write (cons 1 2) to test it concretely. But the 1.5 manual is arguably not the best starting point for learning Common Lisp, as standardized since 1994. You could try the following ones, instead:

Please consult Cliki, the Common Lisp wiki.

coredump
  • 37,664
  • 5
  • 43
  • 77