module Music.Theory.Duration.Hollos2014 where
import Data.List
import Music.Theory.List
import Music.Theory.Permutations.List
import Music.Theory.Set.List
partm :: (Num a, Ord a) => a -> a -> [[a]]
partm :: forall a. (Num a, Ord a) => a -> a -> [[a]]
partm a
i a
j =
let f :: t -> t -> t -> [[t]]
f t
t t
m t
n =
if t
m forall a. Eq a => a -> a -> Bool
== t
1 Bool -> Bool -> Bool
&& t
t forall a. Eq a => a -> a -> Bool
== t
n
then [[t
t]]
else if t
n forall a. Ord a => a -> a -> Bool
< t
m Bool -> Bool -> Bool
|| t
n forall a. Ord a => a -> a -> Bool
< t
1 Bool -> Bool -> Bool
|| t
m forall a. Ord a => a -> a -> Bool
< t
1 Bool -> Bool -> Bool
|| t
t forall a. Ord a => a -> a -> Bool
< t
1
then []
else [forall a. [a] -> [a]
reverse (t
t forall a. a -> [a] -> [a]
: [t]
r) | [t]
r <- t -> t -> t -> [[t]]
f t
t (t
m forall a. Num a => a -> a -> a
- t
1) (t
n forall a. Num a => a -> a -> a
- t
t)] forall a. [a] -> [a] -> [a]
++ (t -> t -> t -> [[t]]
f (t
t forall a. Num a => a -> a -> a
- t
1) t
m t
n)
in forall {t}. (Num t, Ord t) => t -> t -> t -> [[t]]
f (a
j forall a. Num a => a -> a -> a
- a
i forall a. Num a => a -> a -> a
+ a
1) a
i a
j
part :: (Num a, Ord a, Enum a) => a -> [[a]]
part :: forall a. (Num a, Ord a, Enum a) => a -> [[a]]
part a
n = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\a
k -> forall a. (Num a, Ord a) => a -> a -> [[a]]
partm a
k a
n) (forall a. [a] -> [a]
reverse [a
1 .. a
n])
parta :: (Num a, Ord a, Enum a) => a -> [a] -> [[a]]
parta :: forall a. (Num a, Ord a, Enum a) => a -> [a] -> [[a]]
parta a
n [a]
e = forall a. (a -> Bool) -> [a] -> [a]
filter (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [a]
e)) (forall a. (Num a, Ord a, Enum a) => a -> [[a]]
part a
n)
comp :: (Num a, Ord a, Enum a) => a -> [[a]]
comp :: forall a. (Num a, Ord a, Enum a) => a -> [[a]]
comp = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall a. Ord a => [a] -> [[a]]
multiset_permutations forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Num a, Ord a, Enum a) => a -> [[a]]
part
compm :: (Ord a, Num a) => a -> a -> [[a]]
compm :: forall a. (Ord a, Num a) => a -> a -> [[a]]
compm a
k = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall a. Ord a => [a] -> [[a]]
multiset_permutations forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Num a, Ord a) => a -> a -> [[a]]
partm a
k
compa :: (Num a, Ord a, Enum a) => a -> [a] -> [[a]]
compa :: forall a. (Num a, Ord a, Enum a) => a -> [a] -> [[a]]
compa a
n [a]
e = forall a. (a -> Bool) -> [a] -> [a]
filter (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [a]
e)) (forall a. (Num a, Ord a, Enum a) => a -> [[a]]
comp a
n)
compam :: (Num a, Ord a, Enum a) => a -> a -> [a] -> [[a]]
compam :: forall a. (Num a, Ord a, Enum a) => a -> a -> [a] -> [[a]]
compam a
k a
n [a]
e = forall a. (a -> Bool) -> [a] -> [a]
filter (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [a]
e)) (forall a. (Ord a, Num a) => a -> a -> [[a]]
compm a
k a
n)
neck :: (Ord t, Num t) => Int -> [[t]]
neck :: forall t. (Ord t, Num t) => Int -> [[t]]
neck Int
n = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall a. Ord a => [a] -> [[a]]
multiset_cycles [forall a. Int -> a -> [a]
replicate Int
i t
0 forall a. [a] -> [a] -> [a]
++ forall a. Int -> a -> [a]
replicate (Int
n forall a. Num a => a -> a -> a
- Int
i) t
1 | Int
i <- [Int
0 .. Int
n]]
neckm :: (Num a, Ord a) => Int -> Int -> [[a]]
neckm :: forall a. (Num a, Ord a) => Int -> Int -> [[a]]
neckm Int
n Int
m = forall a. (a -> Bool) -> [a] -> [a]
filter ((forall a. Eq a => a -> a -> Bool
== Int
m) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> Int
length forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. Eq a => a -> a -> Bool
== a
1)) (forall t. (Ord t, Num t) => Int -> [[t]]
neck Int
n)
necklaceParts :: (Eq a, Num a) => [a] -> [Int]
necklaceParts :: forall a. (Eq a, Num a) => [a] -> [Int]
necklaceParts [a]
l = forall a. Num a => [a] -> [a]
d_dx (forall a. (a -> Bool) -> [a] -> [Int]
findIndices (forall a. Eq a => a -> a -> Bool
== a
1) [a]
l forall a. [a] -> [a] -> [a]
++ [forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
l])
necklaceWithParts :: (Eq a, Num a) => [Int] -> [a] -> Bool
necklaceWithParts :: forall a. (Eq a, Num a) => [Int] -> [a] -> Bool
necklaceWithParts [Int]
e [a]
l =
let p :: [Int]
p = forall a. (Eq a, Num a) => [a] -> [Int]
necklaceParts [a]
l
in Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Int]
p) Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Int]
e) [Int]
p
necka :: (Num a, Ord a) => Int -> [Int] -> [[a]]
necka :: forall a. (Num a, Ord a) => Int -> [Int] -> [[a]]
necka Int
n [Int]
e = forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. (Eq a, Num a) => [Int] -> [a] -> Bool
necklaceWithParts [Int]
e) (forall t. (Ord t, Num t) => Int -> [[t]]
neck Int
n)
neckam :: (Num a, Ord a) => Int -> Int -> [Int] -> [[a]]
neckam :: forall a. (Num a, Ord a) => Int -> Int -> [Int] -> [[a]]
neckam Int
n Int
m [Int]
e = forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. (Eq a, Num a) => [Int] -> [a] -> Bool
necklaceWithParts [Int]
e) (forall a. (Num a, Ord a) => Int -> Int -> [[a]]
neckm Int
n Int
m)
permi :: [a] -> [[a]]
permi :: forall a. [a] -> [[a]]
permi = forall a. [a] -> [[a]]
permutations_l