Repository : ssh://darcs.haskell.org//srv/darcs/packages/dph On branch : master
http://hackage.haskell.org/trac/ghc/changeset/ea09388bd1761fc2c0eebdc21a76e46500938dad >--------------------------------------------------------------- commit ea09388bd1761fc2c0eebdc21a76e46500938dad Author: Ben Lippmeier <[email protected]> Date: Tue May 3 16:52:08 2011 +1000 Comments for packByTag >--------------------------------------------------------------- dph-prim-interface/interface/DPH_Interface.h | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dph-prim-interface/interface/DPH_Interface.h b/dph-prim-interface/interface/DPH_Interface.h index 6d55f75..3b5c54b 100644 --- a/dph-prim-interface/interface/DPH_Interface.h +++ b/dph-prim-interface/interface/DPH_Interface.h @@ -586,9 +586,25 @@ tagsToSel2 tags = let rep = mkSelRep2 tags -- Packing and Picking -------------------------------------------------------- -packByTag :: Elt a => Array a -> Array Tag -> Tag -> Array a + +-- | Select the elements of an array that have a corresponding tag. +-- +-- @ +-- packByTag [12, 24, 42, 93] [1, 0, 0, 1] 0 +-- = [24, 42] +-- @ +-- +packByTag + :: Elt a + => Array a -- ^ data values + -> Array Tag -- ^ tag values + -> Tag -- ^ the tag of values to select + -> Array a -- ^ data values that had that tag + {-# INLINE_BACKEND packByTag #-} -packByTag xs tags !tag = fsts (filter (\p -> Prelude.snd p == tag) (zip xs tags)) +packByTag xs tags !tag + = fsts (filter (\p -> Prelude.snd p == tag) (zip xs tags)) + pick :: (Elt a, Eq a) => Array a -> a -> Array Bool {-# INLINE pick #-} _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
