newbie question - plists and defvar
Posted: Sat Oct 13, 2012 8:29 pm
Hi all. My first post here (hopefully not the last), so please be patient!
I've set out to learn Lisp (for great good, no less), and started with this "Practical Common Lisp" book (hence question here). But one of the very first examples made me confused. It's about plists.
This works:
CL-USER> (getf (list :a 1 :b 2) :a)
1
But this does not:
CL-USER> (defvar foo (list :a 1 :b 2))
FOO
CL-USER> (getf foo :a)
It gives me an error:
value (1 2 3) is not of the expected type (SATISFIES
CCL::PLISTP).
[Condition of type TYPE-ERROR]
Indeed, when I check:
CL-USER> foo
(1 2 3)
Where are my keyword symbols?!
I did try googling, but nothing on the first page looked like an answer to my question... perhaps I am too clueless at this point to find an answer on my own!
Thanks!
I've set out to learn Lisp (for great good, no less), and started with this "Practical Common Lisp" book (hence question here). But one of the very first examples made me confused. It's about plists.
This works:
CL-USER> (getf (list :a 1 :b 2) :a)
1
But this does not:
CL-USER> (defvar foo (list :a 1 :b 2))
FOO
CL-USER> (getf foo :a)
It gives me an error:
value (1 2 3) is not of the expected type (SATISFIES
CCL::PLISTP).
[Condition of type TYPE-ERROR]
Indeed, when I check:
CL-USER> foo
(1 2 3)
Where are my keyword symbols?!
I did try googling, but nothing on the first page looked like an answer to my question... perhaps I am too clueless at this point to find an answer on my own!
Thanks!