(ns e2-53-54-55
  (:use clojure.test))
(defn memq [item x]
  (cond (empty? x) false
        (= item (first x)) true
        :else (memq item (next x))))
(deftest test-2-53
  (is (= (list 'a 'b 'c)
         '(a b c)))
  (is (= (list (list 'george))
  ; cdr = next
  ;(cdr '((x1 x2) (y1 y2)))
  (is (= (next '((x1 x2) (y1 y2)))
         '((y1 y2))))
  ; cadr = second
  ;(cadr '((x1 x2) (y1 y2)))
  (is (= (second '((x1 x2) (y1 y2)))
         '(y1 y2)))
  ; the closest analog of `pair?` I could find was `sequential?`
  ;(pair? (car '(a short list)))
  (is (= (sequential? (first '(a short list)))
  (is (= (memq 'red '((red shoes) (blue socks)))
  (is (= (memq 'apple '(x (apple sauce) y apple pear))
(defn equal? [a b]
  (cond (and (not (sequential? a)) (not (sequential? b))) (= a b)
        (and (sequential? a) (sequential? b)) (and (equal? (first a) (first b)) (equal? (next a) (next b)))
        :else false))
(deftest test-equal?
  (is (= (equal? 'a 'a) true))
  (is (= (equal? 'a 'b) false))
  (is (= (equal? '(a b) '(a b)) true))
  (is (= (equal? '(a b) '(a a)) false))
  (is (= (equal? '(this is a list) '(this is a list)) true))
  (is (= (equal? '(this is a list) '(this (is a) list)) false)))
(deftest test-abracadabra
  (is (= (first ''abracadabra) 'quote)))