(define (atom? object)
  (not (pair? object)))

;; YOUR CODE HERE
;; Define the "flatten" function
;; (define (flatten l) ...

(define (eql? x y)
  (or (and (atom? x) (atom? y) (eq? x y))
      (and (not (atom? x)) (not (atom? y))
           (eql? (car x) (car y))
           (eql? (cdr x) (cdr y)))))

(define (atomcount lis)
  (cond ((null? lis) 0)
        ((atom? lis) 1)
        (else (+ (atomcount (car lis))
                 (atomcount (cdr lis))))
        )
  )

;; HIGHER-ORDER FUNCTIONS

;; YOUR CODE HERE
;; Define "atomcount2" using map
;; (define (atomcount2 lis) ...

;; Define "flatten2" using map
;; (define (flatten2 lis) ...

(define (foldr op lis id)
  (if (null? lis) id
      (op (car lis)
          (foldr op (cdr lis) id))))

;; YOUR CODE HERE
;;(define (len2 lis)
;;  (foldr ...

(define (foldl op lis id)
  (if (null? lis) id
      (foldl op
             (cdr lis)
             (op id (car lis)))))

;; YOUR CODE HERE
;; (define (rev lis)
;;    (foldl (lambda (x y) (...
