-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add missing methods to VectorOps #3931
Conversation
val nevTraverse = Traverse[NonEmptyVector] | ||
|
||
toNev.fold(F.pure(SortedMap.empty[B, NonEmptyVector[A]])) { nev => | ||
F.map(nevTraverse.traverse(nev)(a => F.tupleLeft(f(a), a))) { vector => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original implementation from ListOps
uses the native NonEmptyList#traverse
method which does not exist for NonEmptyVector
. Therefore Traverse[NonEmptyVector].traverse
is used here instead.
test("scanLeftNev should be consistent with scanLeft")( | ||
forAll { (fa: Vector[Int], b: Int, f: (Int, Int) => Int) => | ||
assert(fa.scanLeftNev(b)(f).toVector === fa.scanLeft(b)(f)) | ||
} | ||
) | ||
|
||
test("scanRightNev should be consistent with scanRight")( | ||
forAll { (fa: Vector[Int], b: Int, f: (Int, Int) => Int) => | ||
assert(fa.scanRightNev(b)(f).toVector === fa.scanRight(b)(f)) | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two tests do not exist for ListOps
's scanLeftNel
and scanRightNel
methods actually.
I wonder, does it make sense to add similar tests to ListSuite
too?
It might be beyond of the PR's scope though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took @LukaJCB's reaction as encouragement to do this, so I added the missing tests to ListSuite
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
7e947c7
to
21c99aa
Compare
Hi guys, sorry for the ping, just to confirm – does this PR require anything else to be done? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry this slipped through the cracks!
Pinging @LukaJCB for a second look |
Adds methods
groupByNev
,groupByNevA
,scanLeftNev
andscanRightNev
toVectorOps
,which are similar to the methods found in
ListOps
.The implementation is mostly copied from
ListOps
and adjusted accordingly.Initial discussion is here.