#lang racket
(require rackunit)

;; ---------------------------------------------------------------------

(define (ex)
  (let ((x 3) (y 4))
    (+
       (let ((z 5)
             (x (* 3 y)))
         (+ (* x y) z))

        (let ((x 6)
              (w (- x y)))
         (+ (* x w) y))      )))

;; ---------------------------------------------------------------------

(define (invert list-of-pairs)
  (let ((swap (lambda (pair)
                (list (cdr pair) (car pair)))))
    (map swap list-of-pairs)) )

;; ---------------------------------------------------------------------
;; list-index, with a stand-alone helper function
;; ---------------------------------------------------------------------

(define (list-index target los)
  (list-index-counted target los 0))

(define (list-index-counted target los count)
  (if (null? los)
      -1
      (if (eq? target (first los))
          count
          (list-index-counted target (rest los) (add1 count)))))

;; ---------------------------------------------------------------------

(check-equal? (ex) 51)

;; ---------------------------------------------------------------------

;; (lambda (x y)         ;; Block 0
;;   ((lambda (a)        ;; Block 1
;;      (x (a y)))
;;   x))

;; ---------------------------------------------------------------------
