I was stumbling through the Arc tutorial when I got sort of confused with this:
Quoted from the Arc Tutorial:
Like Common Lisp assignment, Arc's = is not just for variables, but can reach inside structures. So you can use it to modify lists:
arc> x (a b) arc> (= (car x) 'z) z arc> x (z b)
But lisp is executed recursively, right? It says that car
returns the first value in a list. So:
arc> (car x)
a
which makes sense, but then why isn't (= (car x) 'z)
equal to (= a 'z)
, which would result in:
arc> a
z
arc> x
(a b) ; Note how this hasn't changed
but it doesn't. Instead, it appears that (= (car x) 'z)
seems to have the effects of (= x (list 'z (car (cdr x))))
:
arc> (= x '(a b))
(a b)
arc> (= (car x) 'z)
z
arc> x
(z b)
...
arc> (= x '(a b))
(a b)
arc> (= x (list 'z (car (cdr x))))
(z b)
arc> x
(z b)
So why exactly does (= (car x) 'z)
work that way and what is it that I'm missing here?