phonetic-languages-constraints-array-0.6.2.0: Constraints to filter the needed permutations
Copyright(c) OleksandrZhabenko 2020-2023
LicenseMIT
Maintaineroleksandr.zhabenko@yahoo.com
StabilityExperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010
Extensions
  • BangPatterns
  • FlexibleContexts

Phladiprelio.Constraints

Description

Provides several the most important variants of constraints for the permutations. All the Array here must consists of unique Int starting from 0 to n-1 and the Int arguments must be in the range [0..n-1] though these inner constraints are not checked. It is up to user to check them. Uses arrays instead of vectors. The word "unsafe" in the names means that there is no checking whether the arguments are within the elements of the arrays, this checking is intended to be done elsewhere before applying the functions here. Without such a checking the result are meaningless.

Synopsis

Predicates

unsafeOrderIJ :: Int -> Int -> Array Int Int -> Bool Source #

Being given the data satisfying the constraints in the module header checks whether in the Array the first argument stands before the second one.

unsafeSignDistanceIJ Source #

Arguments

:: Int 
-> Int 
-> Int

Can be of both signs, but not equal to 0. The positive value gives True for the first argument being find earlier in the Array than the second and the distance between their positions are equal to abs d (this argument). The negative value gives True for the second argument being earlier in the Array than the first one and the distance between their positions are equal to abs d (this argument).

-> Array Int Int 
-> Bool 

Being given the data satisfying the constraints in the module header checks whether in the Array the distance between positions of the first two arguments values is equal to the signed third argument.

unsafeUnsignDistanceIJ Source #

Arguments

:: Int 
-> Int 
-> Int

Only for positive values can give True, if the distance between the positions of the elements equal to the first two arguments are equal to this argument. Otherwise, False.

-> Array Int Int 
-> Bool 

Being given the data satisfying the constraints in the module header checks whether in the Array the distance between positions of the first two arguments values is equal to the unsigned third argument. The following is true: if unsafeSignDistanceIJ i j d array == True then unsafeUnsignDistanceIJ i j d array == True, but not necessarily vice versa.

Functions to work with permutations with basic constraints (Array-based)

filterOrderIJ :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> t (Array Int Int) -> t (Array Int Int) Source #

Being given the data satisfying the constraints in the module header returns the elements that satisfy unsafeOrderIJ as a predicate.

unsafeTriples :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) Source #

Being given the data satisfying the constraints in the module header reduces the number of further computations in the foldable structure of the permutations each one being represented as Array Int Int where the elements are all the numbers in the range [0..n-1] without duplication if the arguments are the indeces of the duplicated words or their concatenated combinations in the corresponding line. The first three arguments are the indices of the the triple duplicated elements (words or their concatenated combinations in the phonetic-languages series of packages).

unsafeQuadruples :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) Source #

Being given the data satisfying the constraints in the module header reduces the number of further computations in the foldable structure of the permutations each one being represented as Array Int Int where the elements are all the numbers in the range [0..n-1] without duplication if the arguments are the indeces of the duplicated words or their concatenated combinations in the corresponding line. The first four arguments are the indices of the the quadruple duplicated elements (words or their concatenated combinations in the phonetic-languages series of packages).

With multiple elements specified

unsafeSeveralA :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Array Int Int -> t (Array Int Int) -> t (Array Int Int) Source #

Being given the data satisfying the constraints in the module header reduces the number of further computations in the foldable structure of the permutations each one being represented as Array Int Int where the elements are all the numbers in the range [0..n-1] without duplication. The first argument is the index of the the element (a word or their concatenated combination in the phonetic-languages series of packages), the second argument is Array Int of indices that are in the range [0..n-1]. Filters (and reduces further complex computations) the permutations so that only the variants with the indices in the second argument all stand AFTER the element with the index equal to the first argument.

unsafeSeveralB :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Array Int Int -> t (Array Int Int) -> t (Array Int Int) Source #

Being given the data satisfying the constraints in the module header reduces the number of further computations in the foldable structure of the permutations each one being represented as Array Int Int where the elements are all the numbers in the range [0..n-1] without duplication. The first argument is the index of the the element (a word or their concatenated combination in the phonetic-languages series of packages), the second argument is Array of indices that are in the range [0..n-1]. Filters (and reduces further complex computations) the permutations so that only the variants with the indices in the second argument all stand BEFORE the element with the index equal to the first argument.

With fixed points

fixedPointsG :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Array Int (Int, Int) -> t (Array Int Int) -> t (Array Int Int) Source #

Reduces the number of permutations using filtering leaving just those ones permutations where elements on the first elements in the tuples in the first argument Array places are moved to the places indexed with the second elements in the tuples respectively.

fixedPointsS :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Array Int Int -> t (Array Int Int) -> t (Array Int Int) Source #

A simplified variant of the fixedPointsG function where the specified elements stay on their place and that is why are 'fixed points' in the permutation specified.

Distances between elements

filterSignDistanceIJ :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) Source #

Being given the data satisfying the constraints in the module header returns the elements that satisfy unsafeSignDistanceIJ as a predicate.

filterUnsignDistanceIJ :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) Source #

Being given the data satisfying the constraints in the module header returns the elements that satisfy unsafeUnsignDistanceIJ as a predicate.

filterSignDistanceIJK3 :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) Source #

Being given the data satisfying the constraints in the module header returns the elements that pairwisely (1 and 2, 2 and 3) satisfy unsafeSignDistanceIJ as a predicate.

filterUnsignDistanceIJK3 :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) Source #

Being given the data satisfying the constraints in the module header returns the elements that pairwisely (1 and 2, 2 and 3) satisfy unsafeUnsignDistanceIJ as a predicate.

filterMixedDistanceIJK3 :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => Int -> Int -> Int -> Int -> Int -> t (Array Int Int) -> t (Array Int Int) Source #

Being given the data satisfying the constraints in the module header returns the elements that satisfy both unsafeSignDistanceIJ with the 1st, 2nd and 4th arguments and unsafeUnsignDistanceIJ with the 2nd, 3rd and 5th arguments as predicates.