1. Aleksey Khudyakov
  2. histogram-fill

Commits

Aleksey Khudyakov  committed c2a1d43

Fix constructor binIntN

It was completely broken

  • Participants
  • Parent commits 3850a0c
  • Branches default

Comments (0)

Files changed (1)

File Data/Histogram/Bin/BinInt.hs

View file
         -> Int                  -- ^ Bin size
         -> Int                  -- ^ Upper bound
         -> BinInt
-binIntN lo n hi 
-  | n < 0     = error "Data.Histogram.Bin.BinInt.binIntN: negative bin size"
-  | n > rng   = BinInt lo 1 rng
-  | otherwise = BinInt lo undefined n
+binIntN lo n hi
+  | n  < 0    = error "Data.Histogram.Bin.BinInt.binIntN: negative bin size"
+  | hi < lo   = binIntN hi n lo
+  | n  >= rng = BinInt lo 1 rng
+  | otherwise = BinInt lo (rng `div` n) size
   where
-    rng = hi - lo + 1
+    size = rng `div` n
+    rng  = hi - lo + 1
 
 binIntStep :: Int               -- ^ Lower bound
            -> Int               -- ^ Bin size