summaryrefslogtreecommitdiffhomepage
path: root/Cost.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-08-16 23:53:30 -0400
committerJoey Hess <joeyh@joeyh.name>2016-08-16 23:53:30 -0400
commitfc50d28c84fe7c79d47e89e93e959dbaa68cda5b (patch)
treeaca07262bf025fd4ab54188841e7f75d05872624 /Cost.hs
parentc2eba63d11c748aeebdd3a4a3a5b015ac5e2f2c9 (diff)
downloadkeysafe-fc50d28c84fe7c79d47e89e93e959dbaa68cda5b.tar.gz
improve cost table
Diffstat (limited to 'Cost.hs')
-rw-r--r--Cost.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/Cost.hs b/Cost.hs
index 5aa349c..968cd31 100644
--- a/Cost.hs
+++ b/Cost.hs
@@ -102,3 +102,13 @@ costOverTime (Dollars currcost) thisyear =
let monthdelta = (fromIntegral ((y * 12) - (thisyear * 12))) :: Double
cost = floor $ fromIntegral currcost / 2 ** (monthdelta / 18)
in (Dollars cost, y)
+
+costOverTimeTable :: Dollars -> Year -> [String]
+costOverTimeTable cost thisyear = go [] thisyear $ costOverTime cost thisyear
+ where
+ go t _ [] = reverse t
+ go t yprev ((c, y):ys) =
+ let s = " " ++ show y ++ ":\t" ++ show c
+ in if yprev < y - 1
+ then go (s:" ...":t) y ys
+ else go (s:t) y ys