let non_discarded_cell length discard_cell = let result = ref 0 in try while !result < length do if discard_cell !result then incr result else raise Found done; failwith "Every cell is discarded." with Found -> !result