Skip to content
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

Implement LazyList tailRecM using Iterator.unfold #2964

Merged
merged 1 commit into from
Aug 2, 2019

Conversation

andyscott
Copy link
Contributor

Implements LazyList's tailRecM using Iterator.unfold.

@codecov-io
Copy link

Codecov Report

Merging #2964 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2964      +/-   ##
==========================================
+ Coverage   93.91%   93.93%   +0.02%     
==========================================
  Files         371      371              
  Lines        7061     7061              
  Branches      177      177              
==========================================
+ Hits         6631     6633       +2     
+ Misses        430      428       -2
Impacted Files Coverage Δ
...cala/cats/kernel/instances/FunctionInstances.scala 100% <0%> (+3.03%) ⬆️
testkit/src/main/scala/cats/tests/Helpers.scala 100% <0%> (+4%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f3c979...099b7a7. Read the comment docs.

1 similar comment
@codecov-io
Copy link

Codecov Report

Merging #2964 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2964      +/-   ##
==========================================
+ Coverage   93.91%   93.93%   +0.02%     
==========================================
  Files         371      371              
  Lines        7061     7061              
  Branches      177      177              
==========================================
+ Hits         6631     6633       +2     
+ Misses        430      428       -2
Impacted Files Coverage Δ
...cala/cats/kernel/instances/FunctionInstances.scala 100% <0%> (+3.03%) ⬆️
testkit/src/main/scala/cats/tests/Helpers.scala 100% <0%> (+4%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f3c979...099b7a7. Read the comment docs.

Copy link
Contributor

@kailuowang kailuowang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool! thanks!

@kailuowang kailuowang requested a review from LukaJCB August 2, 2019 16:28
@kailuowang kailuowang merged commit 5494dda into typelevel:master Aug 2, 2019
@kailuowang kailuowang added this to the 2.0.0-RC1 milestone Aug 2, 2019
val b = o.get
advance()
b
val kernel = Iterator.unfold[Option[B], Iterator[Either[A, B]]](Iterator(Left(a))) { it =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two small notes, I bet this would be faster if we did:

unfold[Option[B], List[Iterator[Either[A, B]]])(Iterator.single(Left(a)) :: Nil) {
  case Nil => None
  case nonempty@(h :: t) =>
    if (!h.hasNext) Some((None, t))
    else h.next match {
      case Left(a) => Some((None, fn(a) :: nonempty))
      case Right(b) => Some((Some(b), nonempty))
    } 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants