public static Keyword computeVarianceOrStandardDeviation(ControlFrame frame, Keyword lastmove, boolean standardDeviationP) {
    { Proposition proposition = frame.proposition;
      Stella_Object listarg = (proposition.arguments.theArray)[0];
      Stella_Object listskolem = Logic.argumentBoundTo(listarg);
      Stella_Object resultargg = (proposition.arguments.theArray)[1];
      double sum = 0.0;
      double sum2 = 0.0;
      double x = 0.0;
      int numbercount = 0;

      lastmove = lastmove;
      if ((listskolem != null) &&
          (!Logic.logicalCollectionP(listskolem))) {
        {
          System.out.println();
          System.out.println("Non list appears in second argument to 'VARIANCE or STANDARD-DEVIATION'");
          System.out.println();
        }
;
        return (Logic.KWD_TERMINAL_FAILURE);
      }
      { List listvalue = Logic.assertedCollectionMembers(listskolem, true);

        if (listvalue.emptyP()) {
          return (Logic.KWD_TERMINAL_FAILURE);
        }
        { Stella_Object v = null;
          Cons iter000 = listvalue.theConsList;

          for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
            v = iter000.value;
            { Surrogate testValue000 = Stella_Object.safePrimaryType(v);

              if (Surrogate.subtypeOfIntegerP(testValue000)) {
                { IntegerWrapper v000 = ((IntegerWrapper)(v));

                  x = ((double)(v000.wrapperValue));
                }
              }
              else if (Surrogate.subtypeOfFloatP(testValue000)) {
                { FloatWrapper v000 = ((FloatWrapper)(v));

                  x = v000.wrapperValue;
                }
              }
              else {
                ControlFrame.setFrameTruthValue(frame, Logic.UNKNOWN_TRUTH_VALUE);
                return (Logic.KWD_FAILURE);
              }
            }
            sum = sum + x;
            sum2 = sum2 + (x * x);
            numbercount = numbercount + 1;
          }
        }
        switch (numbercount) {
          case 0: 
            return (Logic.KWD_TERMINAL_FAILURE);
          case 1: 
            return (Logic.selectTestResult(Logic.bindArgumentToValueP(resultargg, FloatWrapper.wrapFloat(0.0), true), true, frame));
          default:
            x = (sum2 - ((sum * sum) / numbercount)) / (numbercount - 1);
            if (standardDeviationP) {
              x = Math.sqrt(x);
            }
            return (Logic.selectTestResult(Logic.bindArgumentToValueP(resultargg, FloatWrapper.wrapFloat(x), true), true, frame));
        }
      }
    }
  }