public static Skolem nthHeadComputation(Skolem list, IntegerWrapper narg) {
    if (!(Logic.enumeratedListP(list))) {
      return (null);
    }
    { int n = narg.wrapperValue;
      Vector elements = list.definingProposition.arguments;
      int nelements = elements.length() - 1;
      List headelements = List.newList();

      if (n < 0) {
        n = nelements + n;
      }
      if ((n < 0) ||
          (n > nelements)) {
        return (null);
      }
      { int i = Stella.NULL_INTEGER;
        int iter000 = 0;
        int upperBound000 = n - 1;
        Cons collect000 = null;

        for (;iter000 <= upperBound000; iter000 = iter000 + 1) {
          i = iter000;
          if (collect000 == null) {
            {
              collect000 = Cons.cons((elements.theArray)[i], Stella.NIL);
              if (headelements.theConsList == Stella.NIL) {
                headelements.theConsList = collect000;
              }
              else {
                Cons.addConsToEndOfConsList(headelements.theConsList, collect000);
              }
            }
          }
          else {
            {
              collect000.rest = Cons.cons((elements.theArray)[i], Stella.NIL);
              collect000 = collect000.rest;
            }
          }
        }
      }
      return (Logic.createLogicalList(headelements));
    }
  }