逻辑编程帮助 [英] Logic programming help
问题描述
A =如果信息为空且输入为空 -删除;
A = if infos !empty and inputs empty - do remove;
B =如果信息为空而输入为空 -确实要添加;
B = if infos empty and inputs !empty - do add;
C =如果信息空且输入与信息相等 -确实要添加;
C = if infos !empty and inputs !equal to infos - do add;
我们可以这样:
if B //it's the most common operation, so at the beginning.
{
//add
}
else
{
//remove
}
elseif(c)
{
//the same add
}
我认为这可能是更好的想法.我可以帮忙吗?
I believe this can be better thinking. Can I have your help?
预先感谢
推荐答案
if (infos != inputs) {
if (empty(inputs)) {
// remove
} else {
// add
}
}
请记住,最外面的条件会检查两个值都永远不会为空(实际上永远不会相同).例如,
Remember, the outermost condition checks that both values are never empty (never the same, actually). E.g.,
A =如果信息为空且输入为空-请删除;
如果输入为空,信息可以不为空.因此,删除.
If inputs is empty infos can not be empty. Therefore, remove.
B =如果信息为空而输入为空-请添加;
C =如果 infos 空并且 inputs 等于infos-做添加;
B = if infos empty and inputs !empty - do add;
C = if infos !empty and inputs !equal to infos - do add;
不同的输入和输入不为空=>不能计算信息是否为空=>添加.
Different and inputs not empty => it doesn't mather whether info is empty => add.
这篇关于逻辑编程帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!