sym 0.11 → 0.11.1
raw patch · 6 files changed
+29/−9 lines, 6 filesdep ~base
Dependency ranges changed: base
Files
- Sym/Internal/CLongArray.hs +13/−0
- Sym/Internal/Util.hs +2/−2
- Sym/Perm/MeshPattern.hs +6/−4
- Sym/Perm/Stat.hs +0/−1
- Sym/Permgram.hs +6/−0
- sym.cabal +2/−2
Sym/Internal/CLongArray.hs view
@@ -21,6 +21,7 @@ , size , at , unsafeAt+ , elemIndices -- * Map , imap@@ -120,6 +121,18 @@ unsafeAt :: CLongArray -> Int -> Int unsafeAt w = fromIntegral . inlinePerformIO . unsafeWith w . flip peekElemOff {-# INLINE unsafeAt #-}++-- | The indices of all elements equal to the query element, in+-- ascending order.+elemIndices :: CLong -> CLongArray -> [Int]+elemIndices x w = inlinePerformIO $ unsafeWith w (go 0)+ where+ n = size w+ go i p+ | i >= n = return []+ | otherwise = do+ y <- peek p+ ([ i | y == x ] ++) `fmap` go (i+1) (advancePtr p 1) -- Map and Zip
Sym/Internal/Util.hs view
@@ -17,14 +17,14 @@ import Data.Set (Set) import qualified Data.Set as S --- | The set of minimal elements with respect to inclusion.+-- | The list of minimal sets with respect to inclusion. minima :: Ord a => [Set a] -> [Set a] minima = minima' . sortBy (comparing S.size) where minima' [] = [] minima' (x:xs) = x : minima' [ y | y<-xs, not (x `S.isSubsetOf` y) ] --- | The set of maximal elements with respect to the given order.+-- | The list of maximal sets with respect to inclusion. maxima :: Ord a => [Set a] -> [Set a] maxima = maxima' . sortBy (comparing $ \x -> -S.size x) where
Sym/Perm/MeshPattern.hs view
@@ -9,7 +9,6 @@ ( MeshPattern (..) , Mesh , Box- , Point , mkPattern , pattern , mesh@@ -37,9 +36,13 @@ import qualified Data.Set as Set import Sym.Internal.Util +-- | A mesh is a, possibly empty, set of shaded boxes.+type Mesh = Set Box++-- | A box is represented by the coordinates of its southwest corner.+type Box = (Int, Int)+ type Point = (Int, Int)-type Box = (Int, Int)-type Mesh = Set Box type PermTwoLine = [Point] data MeshPattern = MP@@ -76,7 +79,6 @@ kVincular :: Int -> Perm -> [MeshPattern] kVincular k w = (flip cols (pattern w) . toList) `fmap` ((1+size w) `choose` k)--- kVincular k w = (\xs -> cols (toList xs) (pattern w)) `fmap` ((1+size w) `choose` k) vincular :: Perm -> [MeshPattern] vincular w = [0..1+size w] >>= flip kVincular w
Sym/Perm/Stat.hs view
@@ -47,7 +47,6 @@ ) where import Prelude hiding (head, last)-import qualified Prelude import Sym.Perm import qualified Sym.Perm.SSYT as Y import qualified Sym.Perm.D8 as D8
Sym/Permgram.hs view
@@ -22,6 +22,8 @@ import Data.Ord import Data.List+import Control.Monad+import Control.Applicative import Sym.Perm (Perm) import qualified Sym.Perm as P import Data.Array.Unboxed@@ -79,6 +81,10 @@ instance Monad Permgram where return x = permgram (P.fromList [0]) [x] w >>= f = joinPermgram $ fmap f w++instance Applicative Permgram where+ pure = return+ (<*>) = ap joinPermgram :: Permgram (Permgram a) -> Permgram a joinPermgram w@(PGram u f) = PGram (P.fromList xs) (listArray (0,m-1) ys)
sym.cabal view
@@ -1,5 +1,5 @@ name: sym-version: 0.11+version: 0.11.1 synopsis: Permutations, patterns, and statistics description: Definitions for permutations with an emphasis on permutation@@ -40,7 +40,7 @@ Sym.Internal.Size Sym.Internal.Util - build-depends: base >= 3 && <= 4.7,+ build-depends: base >= 3 && <= 5, array >=0.4, hashable >=1.1, containers,