This is my Clojure solution to Chapter 2, Exercise 3:
(ns sicp.ch2.ex03 (:require [sicp.ch2.ex02 :as ch2-ex02])) (defn- seg-length [seg] (let [s (ch2-ex02/seg-start seg) e (ch2-ex02/seg-end seg) x (- (ch2-ex02/point-x e) (ch2-ex02/point-x s)) y (- (ch2-ex02/point-y e) (ch2-ex02/point-y s))] (Math/sqrt (+ (* x x) (* y y))))) (defn- make-rect-1 [left-seg bottom-seg] [left-seg bottom-seg]) (def ^:private rect-1-left-seg first) (def ^:private rect-1-bottom-seg second) (defn- rect-1-width [rect-1] (seg-length (rect-1-bottom
This is my Clojure solution to Chapter 2, Exercise 2: