Example #1
0
 // Checks if one of the operands is reducible
 public boolean isOperandsReducible() {
   for (Expression o : operands) {
     if (o.reducible()) {
       return true;
     } else if (!IsValue.isValue(o)) {
       return false;
     }
   }
   return false;
 }
Example #2
0
  public Vector<Expression> reduceOperandsByOneStep() {
    Vector<Expression> new_operands = operands;

    for (int i = 0; i < new_operands.size(); i++) {
      if (new_operands.get(i).reducible()) {
        new_operands.set(i, new_operands.get(i).oneStep());
      } else if (!IsValue.isValue(new_operands.get(i))) {
        return new_operands;
      }
    }
    return new_operands;
  }
Example #3
0
 // Q: When is Function Application reducible?
 // A: When either its operands or operator is reducible
 public boolean reducible() {
   return operator.reducible()
       || (IsValue.isValue(operator) && isOperandsReducible())
       || (IsValue.isValue(operator) && allOperandsAreValues());
 }
Example #4
0
 public boolean allOperandsAreValues() {
   for (Expression o : operands) {
     if (!IsValue.isValue(o)) return false;
   }
   return true;
 }