learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-53.scm (940B)


      1 (define (exercise-2.53)
      2   (test-begin "2.53")
      3   (test-equal
      4       '(a b c)
      5     (list 'a 'b 'c))
      6   (test-equal
      7       '((george))
      8     (list (list 'george)))
      9   (test-equal
     10       '((y1 y2))
     11     ;; '((x1 x2) (y1 y2)) is a pair whose first item is (x1 x2) and
     12     ;; second is a pair whose first item is (y1 y2) and second is nil,
     13     ;; so (cdr '((x1 x2) (y1 y2))) is ((y1 y2)).
     14     (cdr '((x1 x2) (y1 y2))))
     15   (test-equal
     16       '(y1 y2)
     17     ;; the cadr is the first element of the pair whose first item is (y1 y2) and second is nil.
     18     (cadr '((x1 x2) (y1 y2))))
     19   (test-equal
     20       #f
     21     (pair? (car '(a short list))))
     22   (test-equal
     23       #f
     24     ;; No symbol red in the list, so answer is false.
     25     (memq 'red '((red shoes) (blue socks))))
     26   (test-equal
     27       '(red shoes blue socks)
     28     ;; The first element of the first pair is red, so that pair is returned.
     29     (memq 'red '(red shoes blue socks)))
     30   (test-end "2.53"))
     31 
     32 (exercise-2.53)