168k views
0 votes
What is the output of the following Lisp program?

```lisp
(define (b p) (p p))
(define z 1)
(b z)
```

a) 2
b) Error
c) 1
d) 3

User Thedude
by
8.5k points

1 Answer

4 votes

Final answer:

The output of the Lisp program is error due to the incorrect usage of the function definition.

Step-by-step explanation:

The output of the Lisp program is b) Error.

The program defines a function b that takes an argument p and applies p to itself, so calling (b z) means applying z to itself.

However, since z is a number and not a function, an error occurs.

User Kevin Bourrillion
by
8.9k points