Add iterate and iterateIndexed methods for Collections in the stdlib#1113
Add iterate and iterateIndexed methods for Collections in the stdlib#1113stackoverflow wants to merge 4 commits intoapple:mainfrom
iterate and iterateIndexed methods for Collections in the stdlib#1113Conversation
HT154
left a comment
There was a problem hiding this comment.
Looks good, just a couple questions
stdlib/base.pkl
Outdated
There was a problem hiding this comment.
Are there other libraries that also call this iterate?
I also wonder if we should use a clojure-style "return a reduced value" to short-circuit?
In addition to fold, we also have foldBack and reduce. It'd be strange if you can short-circuit here, but not in the other two methods.
There was a problem hiding this comment.
Yeah, that's a good point. I can change the type signature of the folding function to return Element|Reduced<Element> and just change the original functions, instead of creating new ones.
Edit: scratch that. I went with the Clojure approach of having a short-circuiting function that you can call from within any folding/reducing function.
No description provided.