| |||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||
Description | |||||||||||||||||||||||||||||||||||||||||||||
(c) Akimasa Morihata (morihata@ipl.t.u-tokyo.ac.jp), 2009 Library for obtaining optimal lists This library helps us to easily develop efficient program for obtaining optimal lists. Embedded RULES pragma will improve written programs automatically. Its details are explained in the following paper:
| |||||||||||||||||||||||||||||||||||||||||||||
Synopsis | |||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||
Sequence generators | |||||||||||||||||||||||||||||||||||||||||||||
gen :: forall c. Eq c => (forall a b. (b -> b -> b) -> (a -> b) -> b -> (c -> b -> b) -> (c -> a -> a) -> a -> b) -> [[c]] | |||||||||||||||||||||||||||||||||||||||||||||
gen g = g (++) (\a->[a]) [] (\a->map (a:)) (:) [] supply constructors to the functions of the polymorphic type and makes a build form. | |||||||||||||||||||||||||||||||||||||||||||||
inits :: forall a. Eq a => [a] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
identical to List.inits | |||||||||||||||||||||||||||||||||||||||||||||
tails :: forall a. Eq a => [a] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
identical to List.tails | |||||||||||||||||||||||||||||||||||||||||||||
segs :: forall a. Eq a => [a] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
generates all consecutive subsequences | |||||||||||||||||||||||||||||||||||||||||||||
subsequences :: forall a. Eq a => [a] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
identical to Data.List.subsequences | |||||||||||||||||||||||||||||||||||||||||||||
permutations :: forall a. Eq a => [a] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
identical to Data.List.permutations | |||||||||||||||||||||||||||||||||||||||||||||
interleave :: forall a. Eq a => [a] -> [a] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
generate all lists that are "interleaving" of the given two lists | |||||||||||||||||||||||||||||||||||||||||||||
marking :: forall a. Eq a => [a] -> [[Either a a]] | |||||||||||||||||||||||||||||||||||||||||||||
generate all markings by Left or Right | |||||||||||||||||||||||||||||||||||||||||||||
markingBy :: forall a b. Eq b => [a -> b] -> [a] -> [[b]] | |||||||||||||||||||||||||||||||||||||||||||||
generate all markings by the given list of functions | |||||||||||||||||||||||||||||||||||||||||||||
Filtering operations | |||||||||||||||||||||||||||||||||||||||||||||
constraint :: forall a b. (Eq b, Ord a) => (a -> Bool) -> (b -> a -> a) -> a -> [[b]] -> [[b]] | |||||||||||||||||||||||||||||||||||||||||||||
constraint p f e = filter (p . foldr f e) | |||||||||||||||||||||||||||||||||||||||||||||
always :: forall a b. (Eq b, Ord a) => (a -> Bool) -> (b -> a -> a) -> a -> [[b]] -> [[b]] | |||||||||||||||||||||||||||||||||||||||||||||
always p f e = filter (all p . scanr f e) | |||||||||||||||||||||||||||||||||||||||||||||
Maximization/minimization operations | |||||||||||||||||||||||||||||||||||||||||||||
minBySum :: forall a. (Num a, Ord a) => [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
minBySum extracts the lists whose sum is minimum | |||||||||||||||||||||||||||||||||||||||||||||
minByMapSum :: forall a b. (Eq a, Num b, Ord b) => (a -> b) -> [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
minByMapSum f extracts the lists whose sum . map f is minimum | |||||||||||||||||||||||||||||||||||||||||||||
minByAccumSum :: forall a b c. (Eq a, Ord b, Num c, Ord c) => (b -> a -> (b, c)) -> b -> [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
minByAccumSum f e extracts the lists whose sum . snd . mapAccumR f e is minimum | |||||||||||||||||||||||||||||||||||||||||||||
maxBySum :: forall a. (Num a, Ord a) => [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
maxBySum extracts the lists whose sum is maximum | |||||||||||||||||||||||||||||||||||||||||||||
maxByMapSum :: forall a b. (Eq a, Num b, Ord b) => (a -> b) -> [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
maxByMapSum f extracts the lists whose sum . map f is maximum | |||||||||||||||||||||||||||||||||||||||||||||
maxByAccumSum :: forall a b c. (Eq a, Ord b, Num c, Ord c) => (b -> a -> (b, c)) -> b -> [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
maxByAccumSum f e extracts the lists whose sum . snd . mapAccumR f e is maximum | |||||||||||||||||||||||||||||||||||||||||||||
minByLexico :: forall a. Ord a => [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
minByLexico extracts the lists that are the minimum on lexicographic ordering | |||||||||||||||||||||||||||||||||||||||||||||
minByMapLexico :: forall a b. (Eq a, Ord b) => (a -> b) -> [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
minByMapLexico extracts the lists whose map f are the minimum on lexicographic ordering | |||||||||||||||||||||||||||||||||||||||||||||
minByAccumLexico :: forall a b c. (Eq a, Ord b, Ord c) => (b -> a -> (b, c)) -> b -> [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
minByAccumLexico extracts the lists whose snd . mapAccumR f e are the minimum on lexicographic ordering | |||||||||||||||||||||||||||||||||||||||||||||
maxByLexico :: forall a. Ord a => [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
maxByLexico extracts the lists that are the maximum on lexicographic ordering | |||||||||||||||||||||||||||||||||||||||||||||
maxByMapLexico :: forall a b. (Eq a, Ord b) => (a -> b) -> [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
maxByMapLexico f extracts the lists whose map f are the maximum on lexicographic ordering | |||||||||||||||||||||||||||||||||||||||||||||
maxByAccumLexico :: forall a b c. (Eq a, Ord b, Ord c) => (b -> a -> (b, c)) -> b -> [[a]] -> [[a]] | |||||||||||||||||||||||||||||||||||||||||||||
maxByAccumLexico extracts the lists whose snd . mapAccumR f e are the maximum on lexicographic ordering | |||||||||||||||||||||||||||||||||||||||||||||
Produced by Haddock version 2.4.2 |