Tidied up the checkForUnit function in solveConstraints
This commit is contained in:
parent
52054dff9f
commit
1aa914e077
|
@ -92,16 +92,10 @@ solveConstraints p ineq
|
||||||
solve p = (solveUnits p >>* removeRedundant) >>= liftF checkFalsifiable >>= solveNext >>= solve
|
solve p = (solveUnits p >>* removeRedundant) >>= liftF checkFalsifiable >>= solveNext >>= solve
|
||||||
|
|
||||||
checkForUnit :: EqualityConstraintEquation -> Maybe CoeffIndex
|
checkForUnit :: EqualityConstraintEquation -> Maybe CoeffIndex
|
||||||
-- checkForUnit [_] = Nothing
|
checkForUnit = listToMaybe . map fst . filter coeffAbsVal1 . tail . assocs
|
||||||
-- checkForUnit is = listToMaybe $ map fst $ filter (absVal1 . snd) $ zip [1..] (tail is) -- Use [1..] because we've chopped off the 0-index value
|
where
|
||||||
checkForUnit = listToMaybe . map fst . filter (absVal1 . snd) . tail . assocs
|
coeffAbsVal1 :: (a, Integer) -> Bool
|
||||||
|
coeffAbsVal1 (_,x) = (abs x) == 1
|
||||||
|
|
||||||
absVal1 :: Integer -> Bool
|
|
||||||
absVal1 1 = True
|
|
||||||
absVal1 (-1) = True
|
|
||||||
absVal1 _ = False
|
|
||||||
|
|
||||||
|
|
||||||
findFirstUnit :: EqualityProblem -> (Maybe (EqualityConstraintEquation,CoeffIndex),EqualityProblem)
|
findFirstUnit :: EqualityProblem -> (Maybe (EqualityConstraintEquation,CoeffIndex),EqualityProblem)
|
||||||
findFirstUnit [] = (Nothing,[])
|
findFirstUnit [] = (Nothing,[])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user