@@ -15,18 +15,18 @@ before emitting `n` values.
15
15
16
16
This function requires a `Productive` instance proving that the iterator will always emit a value
17
17
after a finite number of skips. If the iterator is not productive or such an instance is not
18
- available, consider using `it.allowNontermination.seekIdx ?` instead of `it.seekIdx ?`. However, it is
19
- not possible to formally verify the behavior of the partial variant.
18
+ available, consider using `it.allowNontermination.atIdxSlow ?` instead of `it.atIdxSlow ?`. However,
19
+ it is not possible to formally verify the behavior of the partial variant.
20
20
-/
21
21
@[specialize]
22
- def Iter.seekIdx ? {α β} [Iterator α Id β] [Productive α Id]
22
+ def Iter.atIdxSlow ? {α β} [Iterator α Id β] [Productive α Id]
23
23
(n : Nat) (it : Iter (α := α) β) : Option β :=
24
24
match it.step with
25
25
| .yield it' out _ =>
26
26
match n with
27
27
| 0 => some out
28
- | k + 1 => it'.seekIdx ? k
29
- | .skip it' _ => it'.seekIdx ? n
28
+ | k + 1 => it'.atIdxSlow ? k
29
+ | .skip it' _ => it'.atIdxSlow ? n
30
30
| .done _ => none
31
31
termination_by (n, it.finitelyManySkips)
32
32
@@ -36,17 +36,17 @@ returns the `n`-th emitted value, or `none` if `it` finished
36
36
before emitting `n` values.
37
37
38
38
This is a partial, potentially nonterminating, function. It is not possible to formally verify
39
- its behavior. If the iterator has a `Productive` instance, consider using `Iter.seekIdx ?` instead.
39
+ its behavior. If the iterator has a `Productive` instance, consider using `Iter.atIdxSlow ?` instead.
40
40
-/
41
41
@[specialize]
42
- partial def Iter.Partial.seekIdx ? {α β} [Iterator α Id β] [Monad Id]
42
+ partial def Iter.Partial.atIdxSlow ? {α β} [Iterator α Id β] [Monad Id]
43
43
(n : Nat) (it : Iter.Partial (α := α) β) : Option β := do
44
44
match it.it.step with
45
45
| .yield it' out _ =>
46
46
match n with
47
47
| 0 => some out
48
- | k + 1 => (⟨it'⟩ : Iter.Partial (α := α) β).seekIdx ? k
49
- | .skip it' _ => (⟨it'⟩ : Iter.Partial (α := α) β).seekIdx ? n
48
+ | k + 1 => (⟨it'⟩ : Iter.Partial (α := α) β).atIdxSlow ? k
49
+ | .skip it' _ => (⟨it'⟩ : Iter.Partial (α := α) β).atIdxSlow ? n
50
50
| .done _ => none
51
51
52
52
end Std.Iterators
0 commit comments