let sub bitarray start length =
  let res = make length false in
  for i = 0 to length - 1 do
    set res i (get bitarray (i + start))
  done;
  res