I have come across a problem where I'm not sure whether I got everything right I learned so far on Lisp.
Basically the task is trivial: Create a list that contains only a single item - the T
literal.
My first approach was:
'(t)
Is this correct? Basically, it evaluates to
(T)
which seems to be correct. As the symbol T
evaluates to itself, this should do the job. But then it got me thinking… If I write
'(s)
I get:
(S)
This looks pretty much the same, but should evaluate in a different way. So I thought about
(list t)
which also results in:
(T)
If I compare the symbols using eq
they are equal:
(eq (car (list t)) (car '(t)))
And also if I I compare both values to T
directly, everything is fine:
(eq (car (list t)) t)
(eq (car '(t)) t)
So, to cut a long story short: '(t)
does the job, doesn't it?