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.
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.
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.
I took @LukaJCB's reaction as encouragement to do this, so I added the missing tests to ListSuite.
7e947c7 to
21c99aa
Compare
|
Hi guys, sorry for the ping, just to confirm – does this PR require anything else to be done? |
djspiewak
left a comment
There was a problem hiding this comment.
Ah, sorry this slipped through the cracks!
|
Pinging @LukaJCB for a second look |
Adds methods
groupByNev,groupByNevA,scanLeftNevandscanRightNevtoVectorOps,which are similar to the methods found in
ListOps.The implementation is mostly copied from
ListOpsand adjusted accordingly.Initial discussion is here.