{-# LANGUAGE BangPatterns #-}
module Languages.UniquenessPeriods.Vector.PropertiesG where
import GHC.Int
import qualified Data.Vector as VB
import String.Languages.UniquenessPeriods.VectorG
diverse ::
Eq a => UniquenessGeneral2 a
-> Int16
diverse :: UniquenessGeneral2 a -> Int16
diverse UniquenessGeneral2 a
v
| UniquenessGeneral2 a -> Bool
forall a. Vector a -> Bool
VB.null UniquenessGeneral2 a
v = Int16
0
| Bool
otherwise = Vector Int16 -> Int16
forall a. Num a => Vector a -> a
VB.sum (Vector Int16 -> Int16)
-> (UniquenessGeneral2 a -> Vector Int16)
-> UniquenessGeneral2 a
-> Int16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int16], a) -> Int16) -> UniquenessGeneral2 a -> Vector Int16
forall a b. (a -> b) -> Vector a -> Vector b
VB.map (\([Int16]
xs,a
_) -> if [Int16] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Int16]
xs then Int16
0::Int16 else [Int16] -> Int16
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
minimum [Int16]
xs) (UniquenessGeneral2 a -> Int16) -> UniquenessGeneral2 a -> Int16
forall a b. (a -> b) -> a -> b
$ UniquenessGeneral2 a
v
diverse1 ::
Eq a => UniquenessGeneral2 a
-> Int16
diverse1 :: UniquenessGeneral2 a -> Int16
diverse1 UniquenessGeneral2 a
v
| UniquenessGeneral2 a -> Bool
forall a. Vector a -> Bool
VB.null UniquenessGeneral2 a
v = Int16
0
| Bool
otherwise = Vector Int16 -> Int16
forall a. Num a => Vector a -> a
VB.sum (Vector Int16 -> Int16)
-> (UniquenessGeneral2 a -> Vector Int16)
-> UniquenessGeneral2 a
-> Int16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int16], a) -> Int16) -> UniquenessGeneral2 a -> Vector Int16
forall a b. (a -> b) -> Vector a -> Vector b
VB.map (\([Int16]
xs,a
_) -> if [Int16] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ((Int16 -> Bool) -> [Int16] -> [Int16]
forall a. (a -> Bool) -> [a] -> [a]
filter (Int16 -> Int16 -> Bool
forall a. Eq a => a -> a -> Bool
/= Int16
1) [Int16]
xs) then Int16
0::Int16 else [Int16] -> Int16
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
minimum ((Int16 -> Bool) -> [Int16] -> [Int16]
forall a. (a -> Bool) -> [a] -> [a]
filter (Int16 -> Int16 -> Bool
forall a. Eq a => a -> a -> Bool
/= Int16
1) [Int16]
xs)) (UniquenessGeneral2 a -> Int16) -> UniquenessGeneral2 a -> Int16
forall a b. (a -> b) -> a -> b
$ UniquenessGeneral2 a
v
diverse1s ::
Eq a => UniquenessGeneral2 a
-> Int16
diverse1s :: UniquenessGeneral2 a -> Int16
diverse1s UniquenessGeneral2 a
v
| UniquenessGeneral2 a -> Bool
forall a. Vector a -> Bool
VB.null UniquenessGeneral2 a
v = Int16
0
| Bool
otherwise = Vector Int16 -> Int16
forall a. Num a => Vector a -> a
VB.sum (Vector Int16 -> Int16)
-> (UniquenessGeneral2 a -> Vector Int16)
-> UniquenessGeneral2 a
-> Int16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int16], a) -> Int16) -> UniquenessGeneral2 a -> Vector Int16
forall a b. (a -> b) -> Vector a -> Vector b
VB.map (\([Int16]
xs,a
_) -> if [Int16] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ((Int16 -> Bool) -> [Int16] -> [Int16]
forall a. (a -> Bool) -> [a] -> [a]
filter (Int16 -> Int16 -> Bool
forall a. Eq a => a -> a -> Bool
/= Int16
1) [Int16]
xs) then Int16
0::Int16 else [Int16] -> Int16
forall a. (Num a, Ord a) => [a] -> a
sumPositiveWithoutMax ((Int16 -> Bool) -> [Int16] -> [Int16]
forall a. (a -> Bool) -> [a] -> [a]
filter (Int16 -> Int16 -> Bool
forall a. Eq a => a -> a -> Bool
/= Int16
1) [Int16]
xs)) (UniquenessGeneral2 a -> Int16) -> UniquenessGeneral2 a -> Int16
forall a b. (a -> b) -> a -> b
$ UniquenessGeneral2 a
v
sumPositiveAndMaxTuple :: (Num a, Ord a) => (a, a) -> [a] -> (a, a)
sumPositiveAndMaxTuple :: (a, a) -> [a] -> (a, a)
sumPositiveAndMaxTuple (a
x1,a
x2) (a
x:[a]
xs)
| a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare a
x2 a
x Ordering -> Ordering -> Bool
forall a. Eq a => a -> a -> Bool
== Ordering
GT = (a, a) -> [a] -> (a, a)
forall a. (Num a, Ord a) => (a, a) -> [a] -> (a, a)
sumPositiveAndMaxTuple (a
x1 a -> a -> a
forall a. Num a => a -> a -> a
+ a
x, a
x2) [a]
xs
| Bool
otherwise = (a, a) -> [a] -> (a, a)
forall a. (Num a, Ord a) => (a, a) -> [a] -> (a, a)
sumPositiveAndMaxTuple (a
x1 a -> a -> a
forall a. Num a => a -> a -> a
+ a
x, a
x) [a]
xs
sumPositiveAndMaxTuple (a
x1, a
x2) [] = (a
x1, a
x2)
sumPositiveAndMaxTuple' :: (Num a, Ord a) => (a, a) -> [a] -> (a, a)
sumPositiveAndMaxTuple' :: (a, a) -> [a] -> (a, a)
sumPositiveAndMaxTuple' (!a
x1,!a
x2) (a
x:[a]
xs)
| a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare a
x2 a
x Ordering -> Ordering -> Bool
forall a. Eq a => a -> a -> Bool
== Ordering
GT = (a, a) -> [a] -> (a, a)
forall a. (Num a, Ord a) => (a, a) -> [a] -> (a, a)
sumPositiveAndMaxTuple' (a
x1 a -> a -> a
forall a. Num a => a -> a -> a
+ a
x, a
x2) [a]
xs
| Bool
otherwise = (a, a) -> [a] -> (a, a)
forall a. (Num a, Ord a) => (a, a) -> [a] -> (a, a)
sumPositiveAndMaxTuple' (a
x1 a -> a -> a
forall a. Num a => a -> a -> a
+ a
x, a
x) [a]
xs
sumPositiveAndMaxTuple' (!a
x1, !a
x2) [] = (a
x1, a
x2)
sumPositiveWithoutMax :: (Num a, Ord a) => [a] -> a
sumPositiveWithoutMax :: [a] -> a
sumPositiveWithoutMax = (a -> a -> a) -> (a, a) -> a
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (-) ((a, a) -> a) -> ([a] -> (a, a)) -> [a] -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a, a) -> [a] -> (a, a)
forall a. (Num a, Ord a) => (a, a) -> [a] -> (a, a)
sumPositiveAndMaxTuple (a
0, a
0)
sumPositiveWithoutMax' :: (Num a, Ord a) => [a] -> a
sumPositiveWithoutMax' :: [a] -> a
sumPositiveWithoutMax' = (a -> a -> a) -> (a, a) -> a
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (-) ((a, a) -> a) -> ([a] -> (a, a)) -> [a] -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a, a) -> [a] -> (a, a)
forall a. (Num a, Ord a) => (a, a) -> [a] -> (a, a)
sumPositiveAndMaxTuple' (a
0, a
0)
diverse2 ::
Eq a => UniquenessGeneral2 a
-> Int16
diverse2 :: UniquenessGeneral2 a -> Int16
diverse2 UniquenessGeneral2 a
v
| UniquenessGeneral2 a -> Bool
forall a. Vector a -> Bool
VB.null UniquenessGeneral2 a
v = Int16
0
| Bool
otherwise = Vector Int16 -> Int16
forall a. Num a => Vector a -> a
VB.sum (Vector Int16 -> Int16)
-> (UniquenessGeneral2 a -> Vector Int16)
-> UniquenessGeneral2 a
-> Int16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([Int16], a) -> Int16) -> UniquenessGeneral2 a -> Vector Int16
forall a b. (a -> b) -> Vector a -> Vector b
VB.map ([Int16] -> Int16
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ([Int16] -> Int16)
-> (([Int16], a) -> [Int16]) -> ([Int16], a) -> Int16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int16], a) -> [Int16]
forall a b. (a, b) -> a
fst) (UniquenessGeneral2 a -> Int16) -> UniquenessGeneral2 a -> Int16
forall a b. (a -> b) -> a -> b
$ UniquenessGeneral2 a
v
{-# INLINE diverse2 #-}
oneProperty :: Ord b => [b] -> b
oneProperty :: [b] -> b
oneProperty [b]
xs
| [b] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [b]
xs = [Char] -> b
forall a. HasCallStack => [Char] -> a
error [Char]
"Languages.UniquenessPeriods.Vector.PropertiesG.oneProperty: empty list. "
| Bool
otherwise = [b] -> b
forall a. [a] -> a
head [b]
xs
{-# INLINE oneProperty #-}
justOneValue2Property :: Ord b => b -> [b]
justOneValue2Property :: b -> [b]
justOneValue2Property = (b -> [b] -> [b]
forall a. a -> [a] -> [a]
:[])
{-# INLINE justOneValue2Property #-}