As always an unreadable or unclear answer is a wrong answer.
Expressions
Enter the following expressions into the Scheme transcript window and write the results. If an expression is entered and nothing happens, check your parentheses!
2. (+ (* 3 12) 10)
3. (+ 2 4 6 8)
4. (define x 12)
5. (define y 20)
6. (* (- y x) (+ x y))
7. (define z (+ x y))
8. z
9. (define ans (+ z (* x 2)))
10. ans
11. (> 50 43)
12. (<= 3 53)
13. (define one 5)
14. (define two 10)
15. (= one 5)
16. (= two (* 2 one))
17. (define name 'george)
18. (eq? name 'george)
19. (eq? name name)
20. (eq? 'name 'george)
21. (and (= one 1) (eq? name 'george))
22. (or (= one 1) (eq? name 'george))
23. (not (= one 1))
The following built-in procedures will identify different types and perform operations on those types. Write the results of each expression. (Note: Most questions will have several results, i.e. number (1) will have four results, so make it CLEAR which results go with each expression.)
(string? 5)
(symbol? 5)
(boolean? 5)
2. (define str 5)
(number? str)
3. (string? str)
(string? 'str)
(string? "str")
4. (define num "this is a string")
(string? num)
5. (symbol? num)
(symbol? str)
(symbol? 'num)
(symbol? 'str)
6. (string-append "Laurie King")
7. (define first "Laurie")
(define second "King")
(string-append first second)
(define long (string-append first second))
long
8. (define false #t)
(boolean? false)
(boolean? #f)
9. (pair? '(1 2 43))
(list? '(1 2 43))
(pair? 21)
(define false '('yes "no" 12))
(pair? false)
10. (cons 'a '(b c))
(cons '(a) '(b c))
(cons 'a 'b)
(cons 'a (cons 'b '() ))
11. (eqv? (+ 4 5 6) (+ 6 5 4))
(eqv? 5 'five)
(eqv? (car '(a b c)) 'a)
12. (equal? (+ 3 2) 5)
(equal? '(1 2 3) '(1 (2 3)))
13. (null? '())
(null? '(1 2))
14. (car (cons 'a '(b c)))
(cdr (cons 'a '(b c)))
(cadr (cons 'a '(b c)))
15. (list? 'a) ;;(pair? ‘a)
16. (list? '(a b c)) ;;(pair? '(a b c))
A list data structure is central to Scheme as an abstract data type. A list is formed by enclosing any number of items within matching left and right parentheses. Write the resulting list for each expression shown below.
2. (define two (cons 'a (cons 'b 'c)))

4. two
5. (define rslt1 (car one))
6. (define rslt2 (car two))
7. (define rslt3 (caddr one))
8. (define rslt4 (caddr two)) ----Why error??
[Try (list? two) and (pair? two)]
9. (define lst (cons (cons 'a '()) (cons 'b (cons 'c '()))))
10. (define get-a (car (car (cdr '(b (a c) d)))))
11. (define get-b (car (cdaddr '(z (y) (x b) (a)))))
12. (define make-new (cons (car '(a b c)) (cdr '(1 2 3))))
13. (define ans1 (equal? (car '(a b)) (car (cdr '(b a)))))
14. (define ans2 (equal? (cons 'a '(b c))
There are two syntactically correct forms for the if-construct:
(if <logical-test> <true-action>)
(define lst2 '(10 20 30))
(define lst3 '(15 25 35))
Using the symbols one and two and the procedure cons, we can construct the list object
(one (two three four))
(one (two three) four)
((one two) (three four))
((b a) (c d))
(((a)))
((d c) (a) b)
The most widely used LISP syntactic form for conditional execution is cond which has the following syntax:
(You may use lists from the above list section to fill in the following cond-construct.)