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
--Haskell as OO code | |
data Card = Card Rank Suit -- my object data | |
deriving (Eq, Show) -- The "Card" objects inherits Eq, Show from its subcomponents (Eq = equals, Show = toString) | |
instance Ord Card where -- I say Card implements the interface Ord | |
compare (Card rank1 _) (Card rank2 _) = compare rank1 rank2 -- Ord has the compare method so I implement it for Card |
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
main = do | |
hspec $ do | |
describe "thisYearCoef" $ do | |
it "starts at 100" $ do | |
thisYearCoef New `shouldBe` 100 | |
it "decreases by 5percent from previous year without accident" $ do | |
thisYearCoef (Existing 100) `shouldBe` 95 | |
thisYearCoef (Existing 95) `shouldBe` 90 | |
thisYearCoef (Existing 80) `shouldBe` 76 | |
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
from fractions import gcd | |
import unittest | |
from itertools import combinations | |
baseMods=[(3, 'fizz'), | |
(5, 'buzz'), | |
(7, 'foo')] | |
mods = [] |
NewerOlder