Skip to content

Instantly share code, notes, and snippets.

@tnoda
Created June 9, 2012 08:05
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 tnoda/2900064 to your computer and use it in GitHub Desktop.
Save tnoda/2900064 to your computer and use it in GitHub Desktop.
learn-you-a-haskell.geometry
(ns learn-you-a-haskell.geometry.core
(:require (learn-you-a-haskell.geometry [sphere :as sphere]
[cuboid :as cuboid]
[cube :as cube])))
(defn -main
"I don't do a whole lot."
[& args]
(print (sphere/volume 10)))
(ns learn-you-a-haskell.geometry.cube
(:require [learn-you-a-haskell.geometry.cuboid :as cuboid]))
(defn volume [side]
(cuboid/volume side side side))
(defn area [side]
(cuboid/area side side side))
(ns learn-you-a-haskell.geometry.cuboid)
(defn- rectangle-area [a b]
(* a b))
(defn volume [a b c]
(rectangle-area a (* b c)))
(defn area [a b c]
(* 2 (+ (rectangle-area a b)
(rectangle-area a c)
(rectangle-area c b))))
(ns learn-you-a-haskell.geometry.sphere)
(defn volume [r]
(* 4/3 Math/PI r r r))
(defn area [r]
(* 4 Math/PI r r))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment