-
Notifications
You must be signed in to change notification settings - Fork 115
[Feature Request] impl Iter2 for Iter[(A, B)] #1319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
https://github.com/moonbitlang/core/blob/main/builtin/iter2.mbt#L67 we can use Iter2::iter() to transform Iter2[A,B] into Iter[(A,b)] |
We need to think about which one is more preferable because we cannot have both under the same name.
|
Rename fn Iter::iteri[T](self : Iter[T]) -> Iter2[Int, T]
|
Then the problem would be when you write |
The behavior of add type AssocList[K,V] @immut/list.T[(K,V)]
fn AssocList::iteri[K,V](self : AssocList[K,V]) -> Iter2[Int,V] {
Iter2::new(fn(yield_) {
loop 0,self._ {
_,Nil => IterContinue
i,Cons(head, tail) => {
if yield_(i,head.1) == IterEnd {
break IterEnd
}
continue i+1,tail
}
}
})
}
test {
let assoc : AssocList[String,String] = Nil
for i,v in assoc.iteri() {
}
} |
What should be the behavior for:
Do you think that for |
K in If we just iter two element, Iter[(A,B)] is enough, maybe IterWithIndex wound be better name |
Then by convention, when implementing Thus for |
typo ´s/iter_as_pair/iter_as_pairs´ we also can add more documents for ´iter_as_pairs´, iterate sequence like associated list |
No description provided.
The text was updated successfully, but these errors were encountered: