In order to manipulate symbols we need a new element in our language: the ability to quote a data object. Suppose we want to construct the list (a b). We can’t accomplish this with (list a b), because this expression constructs a list of the values of a and b rather than the symbols themselves.
So to create a list of symbols a and b, we write (list ‘a ‘b). We call it quotation. Quotation also allows us to type in compound objects, using the conventional printed representation for lists.
One additional primitive used in manipulating symbols is eq?, which takes two symbols as arguments and tests whether they are the same. Using eq?, we can implement a useful procedure called memq.
(define (memq item x)
(cond ((null? x) false)
((eq? item (car x)) x)
(else (memq item (cdr x)))))
(= a b) ⇒ whether two numbers are equal(eqv? a b) ⇒ whether two non-numeric values are equivalent(equal? a b) ⇒ whether two symbols are eq? OR lists are equivalent(eq? a b) ⇒ whether two values represent same object in memory(define (equal? a b)
(or (and (symbol? a) (symbol? b) (eq? a b))
(and (pair? a) (pair? b)
(equal? (car a) (car b))
(equal? (cdr a) (cdr b)))
(and (null? a) (null? b))))
We will consider a very simple symbolic-differentiation program that handles expressions that are built up using only the operations of addition and multiplication with two arguments. Differentiation of any such expression can be carried out by applying reduction rules.