Closed masak closed 1 year ago
Hm, but there's something more going on here that makes it not exactly the same as list
. Look:
> (set L1 '(1 2 3))
(1 2 3)
> (apply cons L1)
(1 2 . 3)
> (apply cons L1 nil)
(1 2 3)
Hm, but there's something more going on here that makes it not exactly the same as
list
.
Right, cons
is actually Kernel's list*
, whose equations (quoted from the specification) are these:
(
list
arg1) ≡ arg1 (list
arg1 arg2 . args) ≡ (cons
arg1 (list*
arg2 . args))
In other words, the implementation of cons
can't actually cheat in a simple way as the OP imagines; list
can, but list*
/cons
can't. So there's nothing much to test, methinks. Closing.
Add a test that makes sure the implementation doesn't just do this:
bellanguage.txt makes this point for
list
:But the same, it feels like, is true of
cons
.