Commits

Aleksey Khudyakov committed 281cb95

Add indexing function for immutable histograms

Comments (0)

Files changed (2)

Data/Histogram.hs

   , HistIndex(..) 
   , histIndex
   , at
+  , atV
+  , atI
     -- * Transformations
   , map
   , bmap
 at :: (Bin bin, Unbox a) => Histogram bin a -> HistIndex bin -> a
 at = H.at
 
+atV :: (Bin bin, Unbox a) => Histogram bin a -> BinValue bin -> a
+atV = H.atV
+
+atI :: (Bin bin, Unbox a) => Histogram bin a -> Int -> a
+atI = H.atI
+
+
+
 ----------------------------------------------------------------
 -- Modify histograms
 ----------------------------------------------------------------

Data/Histogram/Generic.hs

   , HistIndex(..) 
   , histIndex
   , at
+  , atV
+  , atI
     -- * Transformations
   , map
   , bmap
 at :: (Bin bin, Vector v a) => Histogram v bin a -> HistIndex bin -> a
 at (Histogram bin _ v) i = v ! histIndex bin i
 
+-- | Index histogram using bin value
+atV :: (Bin bin, Vector v a) => Histogram v bin a -> BinValue bin -> a
+atV h = at h . Value
+
+-- | Index histogram using vector index
+atI :: (Bin bin, Vector v a) => Histogram v bin a -> Int -> a
+atI h = at h . Index
+
+
+
 ----------------------------------------------------------------
 -- Transformation
 ----------------------------------------------------------------