;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname 2015-11-16-lerner) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
;; A Husky expression (HExp) is one of:
;; -- Boolean
;; -- Number
;; -- Ident
;; -- (list 'const SExp)
;; -- (list 'if HExp HExp HExp)
;; -- (list 'fun [Listof Idents] HExp)
;; -- [Listof HExp]
;; An Ident is a Symbol


'(if (< (abs -5) 6) true 17)
(list 'if '(< (abs -5) 6) true 17)
(list 'if (list '< '(abs -5) 6) true 17)
(list 'if (list '< (list 'abs -5) 6) true 17)

;; ABS is a HExp representing the absolute-value function
(define ABS '(fun (x) (if (< x 0) (- 0 x) x)))

((fun (abs) ((abs (- 5 7)) (abs (- 7 5)))) ABS)


(define (keyword=? kwd s)
  (and (symbol? s) (symbol=? s kwd))

;; eval : HExp -> ISL Value
(define (eval hexp)
  (cond
    [(boolean? hexp) hexp]
    [(number? hexp) hexp]
    [(symbol? hexp) ................]
    [else
     (local
       ((define e1 (first hexp)))
       (cond
         [(keyword=? 'const e1)
          (second hexp)]
         [(keyword=? 'if e1)
          (local ((define c (second hexp))
                  (define t (third hexp))
                  (define f (fourth hexp)))
            (if (eval c)
                (eval t)
                (eval f)))]
         [(keyword=? 'fun e1) ....]
         [else ....]))]))