fromList static method

Logic fromList(
  1. List<Logic> args
)

Implementation

static Logic fromList(List<Logic> args) {
  final bArgs = <Logic>[];
  for (final a in args) {
    if (a is False) {
      return a;
    } else if (a is True) {
      continue; // skip this argument
    }
    bArgs.add(a);
  }

  final sortedArgs = And.flatten(bArgs).toSet().toList()
    ..sort((l1, l2) => l1.hashCode.compareTo(l2.hashCode));

  for (final a in sortedArgs) {
    if (sortedArgs.contains(Not.create(a))) {
      return False();
    }
  }

  if (sortedArgs.length == 1) {
    return sortedArgs.first;
  } else if (sortedArgs.isEmpty) {
    return True();
  }

  return And._(sortedArgs);
}