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