Created
October 26, 2015 05:04
-
-
Save motokiee/145788d6ef82541b1883 to your computer and use it in GitHub Desktop.
Module作る的なことをやったけど、ghciで確認できてない。。。 #CodePiece
This file contains hidden or 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 | |
| ( sphereVolume, | |
| sphereArea, | |
| cubeVolume, | |
| cubeArea, | |
| cuboidArea, | |
| cuboidVolume | |
| ) where | |
| -- exportしている関数 | |
| sphereVolume :: Float -> Float | |
| sphereVolume radius = (4.0 / 3.0) * pi * (radius ^ 3) | |
| sphereArea :: Float -> Float | |
| sphereArea radius = 4 * pi * (radius ^ 2) | |
| cubeVolume :: Float -> Float | |
| cubeVolume side = cuboidVolume side side side | |
| cubeArea :: Float -> Float | |
| cubeArea side = cuboidArea side side side | |
| cuboidVolume :: Float -> Float -> Float -> Float | |
| cuboidVolume a b c = rectArea a b * c | |
| cuboidArea :: Float -> Float -> Float -> Float | |
| cuboidArea a b c = rectArea a b * c + rectArea a c * 2 + rectArea c b * 2 | |
| {- privateな関数 -} | |
| rectArea :: Float -> Float -> Float | |
| rectArea a b = a * b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment