Created
March 4, 2015 11:23
-
-
Save shigemk2/09d0f8799f246ef7ed6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Geometry.Cube | |
( volume | |
, area | |
) where | |
import qualified Geometry.Cuboid as Cuboid | |
volume :: Float -> Float | |
volume side = Cuboid.volume side side side | |
area :: Float -> Float | |
area side = Cuboid.area side side side |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Geometry.Cuboid | |
( volume | |
, area | |
) where | |
volume :: Float -> Float -> Float -> Float | |
volume a b c = rectArea a b * c | |
area :: Float -> Float -> Float -> Float | |
area a b c = rectArea a b * 2 + rectArea a c * 2 + rectArea c b * 2 | |
rectArea :: Float -> Float -> Float | |
rectArea a b = a * b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Geometry.Sphere as Sphere | |
import qualified Geometry.Cuboid as Cuboid | |
import qualified Geometry.Cube as Cube | |
main = do | |
print $ Cube.volume 4.0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Geometry.Sphere | |
( volume | |
, area | |
) where | |
volume :: Float -> Float | |
volume radius = (4.0 / 3.0) * pi * (radius ^ 3) | |
area :: Float -> Float | |
area radius = 4 * pi * (radius ^ 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment