本文整理汇总了Java中com.sri.ai.util.Util.mapIntoArrayList方法的典型用法代码示例。如果您正苦于以下问题:Java Util.mapIntoArrayList方法的具体用法?Java Util.mapIntoArrayList怎么用?Java Util.mapIntoArrayList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sri.ai.util.Util
的用法示例。
在下文中一共展示了Util.mapIntoArrayList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeOfFunctor
import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
* Gets a function application and its type <code>T</code>, and returns the inferred type of its functor,
* which is <code>'->'('x'(T1, ..., Tn), T)</code>, where <code>T1,...,Tn</code> are the types.
*/
public static Expression getTypeOfFunctor(Expression functionApplication, Expression functionApplicationType, Registry registry) {
Expression result;
if (functionApplication.getSyntacticFormType().equals(FunctionApplication.SYNTACTIC_FORM_TYPE)) {
List<Expression> argumentTypes = Util.mapIntoArrayList(functionApplication.getArguments(), new GetType(registry));
if (argumentTypes.contains(null)) {
result = null; // unknown type
}
else {
result = FunctionType.make(functionApplicationType, argumentTypes);
}
}
else {
throw new Error("getTypeOfFunctor applicable to function applications only, but invoked on " + functionApplication);
}
return result;
}
示例2: simplify
import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
* Returns FALSE if given disequality has equal arguments, TRUE if they contain distinct constants,
* and the disequality itself otherwise.
*/
public static Expression simplify(Expression disequality, Context context) {
Expression result;
if (disequality.get(0).equals(disequality.get(1))) {
result = Expressions.FALSE;
}
else {
Set<Expression> constants = new LinkedHashSet<Expression>();
Set<Expression> nonConstants = new LinkedHashSet<Expression>();
Util.collect(disequality.getArguments(), constants, context.getIsUniquelyNamedConstantPredicate(), nonConstants);
if (constants.size() > 1) {
result = Expressions.TRUE;
}
else if (constants.size() == 1 && constants.contains(Expressions.FALSE)) {
result = And.make(new ArrayList<Expression>(nonConstants));
}
else if (constants.size() == 1 && constants.contains(Expressions.TRUE)) {
ArrayList<Expression> negatedNonConstants = Util.mapIntoArrayList(nonConstants, e -> Not.make(e));
result = And.make(new ArrayList<Expression>(negatedNonConstants));
}
else {
result = disequality;
}
}
return result;
}
示例3: simplify
import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
* Returns TRUE if given equality has all-equal arguments, FALSE if they contain distinct constants,
* and the equality itself otherwise.
* Note that this is much faster than eliminating duplicates as well, which requires constructing another equality.
*/
public static Expression simplify(Expression equality, Context context) {
Expression result;
if (Util.allEqual(equality.getArguments())) {
result = Expressions.TRUE;
}
else {
Set<Expression> constants = new LinkedHashSet<Expression>();
Set<Expression> nonConstants = new LinkedHashSet<Expression>();
Util.collect(equality.getArguments(), constants, context.getIsUniquelyNamedConstantPredicate(), nonConstants);
if (constants.size() > 1) {
result = Expressions.FALSE;
}
else if (constants.size() == 1 && constants.contains(Expressions.TRUE)) {
result = And.make(new ArrayList<Expression>(nonConstants));
}
else if (constants.size() == 1 && constants.contains(Expressions.FALSE)) {
ArrayList<Expression> negatedNonConstants = Util.mapIntoArrayList(nonConstants, e -> Not.make(e));
result = And.make(new ArrayList<Expression>(negatedNonConstants));
}
else {
result = equality;
}
}
return result;
}
示例4: makeDefaultIntensionalUniSetFromLabelAndSubTrees
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static Expression makeDefaultIntensionalUniSetFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
if (subTreeObjects.length == 1 && subTreeObjects[0] instanceof Collection) {
subTreeObjects = ((Collection) subTreeObjects[0]).toArray();
}
ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
if (subTreeExpressions.size() == 1) {
subTreeExpressions = new ArrayList<Expression>(Expressions.ensureListFromKleeneList(subTreeExpressions.get(0)));
}
Expression scopingExpression = subTreeExpressions.get(0);
IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet(
(scopingExpression == null || scopingExpression.numberOfArguments() == 0)?
Util.list()
: new ArrayList<Expression>(Expressions.ensureListFromKleeneList(scopingExpression.get(0))));
Expression conditioningSyntaxTree = subTreeExpressions.get(2);
Expression condition = conditioningSyntaxTree == null? Expressions.TRUE : conditioningSyntaxTree.get(0);
Expression result = new DefaultIntensionalUniSet(indexExpressions, subTreeExpressions.get(1), condition);
return result;
}
示例5: makeDefaultIntensionalMultiSetFromLabelAndSubTrees
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static Expression makeDefaultIntensionalMultiSetFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
if (subTreeObjects.length == 1 && subTreeObjects[0] instanceof Collection) {
subTreeObjects = ((Collection) subTreeObjects[0]).toArray();
}
ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
if (subTreeExpressions.size() == 1) {
subTreeExpressions = new ArrayList<Expression>(Expressions.ensureListFromKleeneList(subTreeExpressions.get(0)));
}
Expression scopingExpression = subTreeExpressions.get(0);
IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet(
(scopingExpression == null || scopingExpression.numberOfArguments() == 0)?
Util.list()
: new ArrayList<Expression>(Expressions.ensureListFromKleeneList(scopingExpression.get(0))));
Expression conditioningSyntaxTree = subTreeExpressions.get(2);
Expression condition = conditioningSyntaxTree == null? Expressions.TRUE : conditioningSyntaxTree.get(0);
Expression result = new DefaultIntensionalMultiSet(indexExpressions, subTreeExpressions.get(1), condition);
return result;
}
示例6: makeDefaultCountingFormulaExpressionFromLabelAndSubTrees
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static Expression makeDefaultCountingFormulaExpressionFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
Expression indexExpressionsKleeneList = subTreeExpressions.get(0);
IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet(ensureListFromKleeneList(indexExpressionsKleeneList));
Expression body = subTreeExpressions.get(1);
Expression result = new DefaultCountingFormula(indexExpressions, body);
return result;
}
示例7: makeDefaultLambdaExpressionFromLabelAndSubTrees
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static Expression makeDefaultLambdaExpressionFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
Expression indexExpressionsKleeneList = subTreeExpressions.get(0);
IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet(ensureListFromKleeneList(indexExpressionsKleeneList));
Expression body = subTreeExpressions.get(1);
Expression result = new DefaultLambdaExpression(indexExpressions, body);
return result;
}
示例8: makeDefaultUniversallyQuantifiedFormulaFromLabelAndSubTrees
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static Expression makeDefaultUniversallyQuantifiedFormulaFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
Expression indexExpressionsKleeneList = subTreeExpressions.get(0);
IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet(ensureListFromKleeneList(indexExpressionsKleeneList));
Expression body = subTreeExpressions.get(1);
Expression result = new DefaultUniversallyQuantifiedFormula(indexExpressions, body);
return result;
}
示例9: makeDefaultExistentiallyQuantifiedFormulaFromLabelAndSubTrees
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static Expression makeDefaultExistentiallyQuantifiedFormulaFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
Expression indexExpressionsKleeneList = subTreeExpressions.get(0);
IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet(ensureListFromKleeneList(indexExpressionsKleeneList));
Expression body = subTreeExpressions.get(1);
Expression result = new DefaultExistentiallyQuantifiedFormula(indexExpressions, body);
return result;
}
示例10: makeDefaultFunctionApplicationFromLabelAndSubTrees
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static Expression makeDefaultFunctionApplicationFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
if (subTreeObjects.length == 1 && subTreeObjects[0] instanceof Collection) {
subTreeObjects = ((Collection) subTreeObjects[0]).toArray();
}
Expression labelExpression = makeFromObject(label);
ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
Expression result = new DefaultFunctionApplication(labelExpression, subTreeExpressions);
return result;
}
示例11: makeDefaultTupleFromLabelAndSubTrees
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static Expression makeDefaultTupleFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
if (subTreeObjects.length == 1 && subTreeObjects[0] instanceof Collection) {
subTreeObjects = ((Collection) subTreeObjects[0]).toArray();
}
ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
if (subTreeExpressions.size() == 1) {
subTreeExpressions = new ArrayList<Expression>(Expressions.ensureListFromKleeneList(subTreeExpressions.get(0)));
}
Expression result = new DefaultTuple(subTreeExpressions);
return result;
}
示例12: makeDefaultExtensionalUniSetFromLabelAndSubTrees
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static Expression makeDefaultExtensionalUniSetFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
if (subTreeObjects.length == 1 && subTreeObjects[0] instanceof Collection) {
subTreeObjects = ((Collection) subTreeObjects[0]).toArray();
}
ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
if (subTreeExpressions.size() == 1) {
subTreeExpressions = new ArrayList<Expression>(Expressions.ensureListFromKleeneList(subTreeExpressions.get(0)));
}
Expression result = new DefaultExtensionalUniSet(subTreeExpressions);
return result;
}
示例13: makeDefaultExtensionalMultiSetFromLabelAndSubTrees
import com.sri.ai.util.Util; //导入方法依赖的package包/类
private static Expression makeDefaultExtensionalMultiSetFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
if (subTreeObjects.length == 1 && subTreeObjects[0] instanceof Collection) {
subTreeObjects = ((Collection) subTreeObjects[0]).toArray();
}
ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
if (subTreeExpressions.size() == 1) {
subTreeExpressions = new ArrayList<Expression>(Expressions.ensureListFromKleeneList(subTreeExpressions.get(0)));
}
Expression result = new DefaultExtensionalMultiSet(subTreeExpressions);
return result;
}
示例14: applyJavaFunctionToArgumentsAndReAssembleFunctionApplication
import com.sri.ai.util.Util; //导入方法依赖的package包/类
/**
* Given a function <code>F</code> and a function application <code>f(a1, ..., an)</code>,
* returns <code>f(F(a1), ..., F(an))</code>.
*/
public static Expression applyJavaFunctionToArgumentsAndReAssembleFunctionApplication(Function<Expression, Expression> function, Expression expression) {
Expression result;
Expression functor = expression.getFunctor();
List<Expression> arguments = expression.getArguments();
List<Expression> resultingArguments = Util.mapIntoArrayList(arguments, function);
if (Util.sameInstancesInSameIterableOrder(arguments, resultingArguments)) {
result = expression;
}
else {
result = apply(functor, resultingArguments);
}
return result;
}
示例15: makeSyntaxTree
import com.sri.ai.util.Util; //导入方法依赖的package包/类
protected DefaultCompoundSyntaxTree makeSyntaxTree() {
DefaultCompoundSyntaxTree result;
ArrayList<SyntaxTree> elementsSyntaxTrees = Util.mapIntoArrayList(elementsDefinitions, e -> e == null? null : e.getSyntaxTree());
SyntaxTree kleeneList = SyntaxTrees.makeKleeneListIfNeeded(elementsSyntaxTrees);
result = new DefaultCompoundSyntaxTree(getLabel(), kleeneList);
return result;
}