多重コンテナ
多重のmap
code:haskell
fmap . fmap :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
code:haskell
concat :: a -> a
mconcat :: Monoid a => a -> a join :: Monad m => m (m a) -> m a
fold :: (Foldable f, Monoid a) => f a -> a
fold = foldMap id
MaybeのリストからJustな値を取り出す(Nothingが一つでも入っていれば諦める) code:haskell
sequence :: (Applicative f, Traversable t) => t (f a) -> f (t a)
MaybeのリストからJustな値を取り出す(Nothingを無視する)
code:haskell
catMaybes :: Filterable f => f (Maybe a) -> f a -- witherable: Data.Witherable
foldMap toList :: Foldable f => f a -> a code:haskell
code:haskell
transpose :: a -> a -- Data.List
getZipList . traverse ZipList :: Traversable t => t b -> t b リストを固定長のリストに分割
code:haskell
chunksOf :: Int -> e -> e -- split: Data.List.Split Mapの転置
code:haskell
unionsWith (<>) . mapWithKey (fmap . singleton) :: Map i (Map j a) -> Map j (Map i a)
foldMapWithKey (fmap . singleton) :: MonoidalMap i (MonoidalMap j a) -> MonoidalMap j (MonoidalMap i a) -- monoidal-containers
code:haskell
(!*) :: (Foldable t, Num a, Applicative f, Applicative t) => row a -> row (col a) -> col a
v !* m = foldl' (liftA2 (+)) (pure 0) $ liftA2 (fmap . (*)) v m
行列と列ベクトルの積
code:haskell
(*!) :: (Functor row, Applicative col, Foldable col, Num a) => row (col a) -> col a -> row a
m *! v = fmap (sum . liftA2 (*) v) m
冪集合(リスト)
code:haskell
],2,1,1,2,0,0,2,0,1,[0,1,2 code:haskell
distribute :: (Functor f, Distributive g) => f (g a) -> g (f a)
対角成分の抽出
リカーシブスローダウン