Flux
Flux

Reputation: 10950

Are two empty lists guaranteed to be 'eq?' in Racket?

Is (eq? '() '()) guaranteed to be true in Racket?

If not mistaken, two empty lists are guaranteed to be eq? in R7RS, but I want to know if Racket also provides such a guarantee.

I have read the documentation, but I couldn't find the answer.

Upvotes: 2

Views: 53

Answers (1)

soegaard
soegaard

Reputation: 31145

Yes. The behaviour of eq? more or less follows eq? from Scheme.

The documentation on eq? could be clearer though. The documentation on lists has the following to say:

A list is recursively defined: it is either the constant null, or it is a pair whose second value is a list.

So the empty list is a constant - which means it is unique.

Upvotes: 3

Related Questions