<commit_before>(ns sicp.chapter2.1-4)

;;;; 2.1  Introduction to Data Abstraction

;;; 2.1.4  Extended Exercise: Interval Arithmetic
<commit_msg>2.1.4  Extended Exercise: Interval Arithmetic<commit_after>(ns sicp.chapter2.1-4)

;;;; 2.1  Introduction to Data Abstraction

;;; 2.1.4  Extended Exercise: Interval Arithmetic

(declare make-interval lower-bound upper-bound)

(defn add-interval [x y]
  (make-interval (+ (lower-bound x) (lower-bound y))
                 (+ (upper-bound x) (upper-bound y))))

(defn mul-interval [x y]
  (let [p1 (* (lower-bound x) (lower-bound y))
        p2 (* (lower-bound x) (upper-bound y))
        p3 (* (upper-bound x) (lower-bound y))
        p4 (* (upper-bound x) (upper-bound y))]
    (make-interval (min p1 p2 p3 p4)
                   (max p1 p2 p3 p4))))

(defn div-interval [x y]
  (mul-interval x
                (make-interval (/ 1.0 (upper-bound y))
                               (/ 1.0 (lower-bound y)))))

;; Exercise 2.7
;; TODO

;; Exercise 2.8
;; TODO

;; Exercise 2.9
;; TODO

;; Exercise 2.10
;; TODO

;; Exercise 2.11
;; TODO

;; Exercise 2.12
;; TODO

;; Exercise 2.13
;; TODO

;; Exercise 2.14
;; TODO

;; Exercise 2.15
;; TODO

;; Exercise 2.16
;; TODO

{'fraction_non_alphanumeric': 0.16432700247729148, 'fraction_numerical': 0.05119735755573906, 'mean_word_length': 2.4727793696275073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4301269', 'n_tokens_mistral': 489, 'n_tokens_neox': 437, 'n_words': 124}