count cycle lengths in skip_max_list_cycle
@@ -462,13 +462,22 @@ fn step(heap: &Heap, mut value: HeapCellValue) -> usize {
hare = step(&self.heap, self.heap[hare]);
}
+ let mut count = 1;
+
while hare != tortoise {
hare = step(&self.heap, self.heap[hare]);
tortoise = step(&self.heap, self.heap[tortoise]);
+
+ count += 1;
}
+ let target_n = self.store(self.deref(self.registers[1]));
+ self.unify_fixnum(Fixnum::build_with(count), target_n);
+
+ if !self.fail {
unify!(self, self.registers[4], self.heap[hare]);
}
+ }
fn finalize_skip_max_list(&mut self, n: i64, value: HeapCellValue) {
let target_n = self.store(self.deref(self.registers[1]));
