Skip to content

Instantly share code, notes, and snippets.

@zdennis

zdennis/core.clj Secret

Created July 14, 2012 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zdennis/89d7095f77f1b7d96801 to your computer and use it in GitHub Desktop.
Save zdennis/89d7095f77f1b7d96801 to your computer and use it in GitHub Desktop.
(ns drunken-cockroach.core
(:require [drunken-cockroach.point :as point :only [create]])
(:require [drunken-cockroach.rectangle :as rectangle]))
(defn -main [& args])
(ns drunken-cockroach.point)
(defstruct point :x :y)
(defn create [x y] (struct point x y))
(defn add [point1 point2]
(let [
x1 (get point1 :x)
x2 (get point2 :x)
y1 (get point1 :y)
y2 (get point2 :y)]
(struct point
(+ x1 x2)
(+ y1 y2))))
(defn max [point1 point2]
(let [
x1 (get point1 :x)
x2 (get point2 :x)
y1 (get point1 :y)
y2 (get point2 :y)]
(cond
(> y2 y1) point2
(> x2 x1) point2
:else point1)))
(defn min [point1 point2]
(let [
x1 (get point1 :x)
x2 (get point2 :x)
y1 (get point1 :y)
y2 (get point2 :y)]
(cond
(< y2 y1) point2
(< x2 x1) point2
:else point1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment