-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String Formatierung #63
Comments
I'm wondering whether in some context the possibility of choosing logic-tasks/src/Tasks/LegalProposition/PrintIllegal.hs Lines 87 to 89 in 9b41859
@nimec01, can you try to trace under what conditions that |
I don't really get what you mean by "under what conditions that
This shows me that there shouldn't be any problems regarding "too many spaces". This would only be the case if |
I meant exactly what you did: Finding out which situations/call paths actually reach that one occurrence of About the subject matter: Indeed I think it would be better to display As to how to make that reduction happen: It's probably not worth it to refactor all the code and try to avoid generating that adjacent space there in the first place. Instead, the following strategy/hack should work:
|
ifUseIllegal :: Bool -> Bool -> SynTree BinOp Char -> String -> Gen String
ifUseIllegal useBug notFirstLayer synTree usedLiterals =
let
nodeNum = treeNodes synTree
replace' a b = fmap (replace a b)
in
if not useBug
then return (normalShow synTree)
else frequency
[ (1, replace' "_ " "" (replace' " _" "" (implementIllegal notFirstLayer synTree usedLiterals)))
, (fromIntegral nodeNum - 1, subTreeIllegal notFirstLayer synTree usedLiterals)
] This change should allow me to replace If I go ahead and change |
Sounds strange. Maybe some kind of side effect of using Unicode for displaying |
I did some more testing and found out that you apparently cannot change a value encapsulated in a implementIllegal :: Bool -> SynTree BinOp Char -> String -> Gen String
implementIllegal notFirstLayer (Binary operator a b) usedLiterals =
illegalShow notFirstLayer a b usedLiterals operator
implementIllegal _ (Not a) usedLiterals = do
letter <- elements usedLiterals
elements $ map (++ (' ' : normalShow a)) ([letter] : map showOperator allBinaryOperators)
implementIllegal _ (Leaf _) _ = do
operator <- elements (showOperatorNot : map showOperator allBinaryOperators)
elements [operator,"_"]
generateLegalPropositionInst :: LegalPropositionConfig -> Gen LegalPropositionInst
generateLegalPropositionInst LegalPropositionConfig {syntaxTreeConfig = SynTreeConfig {..}, ..} = do
treeList <- vectorOf
(fromIntegral formulas)
(genSynTree (minNodes, maxNodes)
maxDepth
usedLiterals
atLeastOccurring
allowArrowOperators
maxConsecutiveNegations
minUniqueBinOperators
)
`suchThat` (not . similarExist)
serialsOfWrong <- vectorOf (fromIntegral illegals) (choose (1, fromIntegral formulas) )`suchThat` listNoDuplicate
serialsOfBracket <- vectorOf
(fromIntegral bracketFormulas)
(choose (1, fromIntegral formulas))
`suchThat` (listNoDuplicate . (++ serialsOfWrong))
pseudoFormulas <- genPseudoList serialsOfWrong serialsOfBracket treeList `suchThat` noSimilarFormulas
return $ LegalPropositionInst
{ serialsOfWrong = fromList serialsOfWrong
, pseudoFormulas = map replaceUnderscores pseudoFormulas
, correctTrees = [ tree | (index, tree) <- zip [1..] treeList, index `notElem` serialsOfWrong ]
, showSolution = printSolution
, addText = extraText
}
where replaceUnderscores = DLE.replace "_ " "" . DLE.replace " _" ""
The first formula here would have included a " _" right before the first closing bracket. |
I don't think the problem can be Rather, my suggested place of adding the replacing to I'll comment further in #114. |
Teilweise entstehen auffällig große Lücken in (illegalen) Formeln:
The text was updated successfully, but these errors were encountered: