-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solve 'Geometry Basics: Circle Area in 2D' kata
- Loading branch information
1 parent
de093f8
commit 142753c
Showing
7 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Geometry (circleArea) where | ||
|
||
import Preloaded (Point(..), Circle(..)) | ||
|
||
-- https://www.codewars.com/kata/58e3f824a33b52c1dc0001c0/train/haskell | ||
|
||
circleArea :: Circle -> Double | ||
circleArea (Circle _ r) = r * r * pi |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module GeometrySpec where | ||
|
||
import Geometry (circleArea) | ||
import Preloaded | ||
import Test.Hspec | ||
import Test.Hspec.Codewars | ||
|
||
spec :: Spec | ||
spec = do | ||
describe "Fixed Tests" $ do | ||
it "circleArea $ Circle (Point 10 10) 30" $ do | ||
circleArea (Circle (Point 10 10) 30) `shouldBeApprox` 2827.4333882308138 | ||
it "circleArea $ Circle (Point 25 (-70)) 30" $ do | ||
circleArea (Circle (Point 25 (-70)) 30) `shouldBeApprox` 2827.4333882308138 | ||
it "circleArea $ Circle (Point (-15) 5) 0" $ do | ||
circleArea (Circle (Point (-15) 5) 0) `shouldBeApprox` 0 | ||
it "circleArea $ Circle (Point (-15) 5) 12.5" $ do | ||
circleArea (Circle (Point (-15) 5) 12.5) `shouldBeApprox` 490.8738521234052 |
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