From 408997ea02dec897934b176fe57115bdb4f60f63 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Wed, 20 Jan 2010 12:05:34 +0000 Subject: more defined fromRows/fromColumns/fromBlocks --- lib/Data/Packed/Internal/Common.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/Data/Packed/Internal/Common.hs') diff --git a/lib/Data/Packed/Internal/Common.hs b/lib/Data/Packed/Internal/Common.hs index 629016d..972cd7d 100644 --- a/lib/Data/Packed/Internal/Common.hs +++ b/lib/Data/Packed/Internal/Common.hs @@ -18,7 +18,7 @@ module Data.Packed.Internal.Common( Adapt, app1, app2, app3, app4, (//), check, - partit, common, + partit, common, compatdim, fi ) where @@ -41,6 +41,12 @@ common f = commonval . map f where commonval [a] = Just a commonval (a:b:xs) = if a==b then commonval (b:xs) else Nothing +-- | common value with \"adaptable\" 1 +compatdim :: [Int] -> Maybe Int +compatdim [] = Nothing +compatdim [a] = Just a +compatdim (a:b:xs) = if a==b || a==1 || b==1 then compatdim (max a b:xs) else Nothing + -- | postfix function application (@flip ($)@) (//) :: x -> (x -> y) -> y infixl 0 // -- cgit v1.2.3