static L<LongRange> chunks(long end, long chunkSize) {
  ret chunks(0, end, chunkSize);
}

static L<LongRange> chunks(long start, long end, long chunkSize) {
  new L<LongRange> l;
  long i = start;
  while (i < end) {
    l.add(LongRange(i, min(end, i+chunkSize)));
    i += chunkSize;
  }
  ret l;
}

static <A> LL<A> chunks(int chunkSize, L<A> l) {
  ret listToChunks(chunkSize, l);
}