Skip to content

Instantly share code, notes, and snippets.

@zdennis zdennis/core.clj Secret
Created Jul 14, 2012

Embed
What would you like to do?
(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
You can’t perform that action at this time.