Files
  • main.hs
main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- | addCentury takes a two-digit year, and a four-digit year
-- and prepends the century from the latter to the former.
addCentury :: Int -> Int -> Int
addCentury n m = n + (m `div` 100) * 100

-- | averageYear takes a tuple of ints and returns the statistical mean
averageYear :: (Int, Int) -> Int
averageYear = (`div` 2) . (uncurry (+))

main :: IO ()
main = do
  let a = 1858
      b = 60
      b' = addCentury b a
      average = averageYear (a, b')
  putStrLn $ show average
GHCi, version 8.6.3