.slidingN using tuples - #3727
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3727 +/- ##
==========================================
- Coverage 90.24% 90.02% -0.22%
==========================================
Files 390 390
Lines 8865 8886 +21
Branches 255 261 +6
==========================================
Hits 8000 8000
- Misses 865 886 +21 |
|
Looks good enough to try and solicit feedback. The one thing which sticks out to me is the fact that the functions can return an empty list when the size of the foldable is less than the size of the window. I personally thing this is sensible, as the sliding function is not useful in these situations. Discussion/feedback welcome though! |
|
I think this is neat. It deserves a better review, but quick response:
That's inconsistent with standard library's sliding, but I don't see what else you can do here other than document it, which you did. It's a fundamental tradeoff of having fixed-size windows. |
|
This is cool. One thing I wonder about is, rather than materializing a list, what about a fold? def sliding2FoldLeft[B](init: B)(fn: (B, (A, A)) => B): BThen you can recover the list by But in many cases, you might not need to materialize everything, so could go ahead and tear it down there. |
|
Thanks for the input @johnynek , the main motivation of this change was to be a more typesafe re: def sliding2M[M[_]: Monoid]: M[(A, A)]But maybe |
|
Test failure was because of a flaky test. This is fixed on master. |
This is a kind reminder to run
sbt +prePRand commit the changed files, if any, before submitting.Discussed a little on gitter, this is basically a tupleified version of scala sliding.
These functions differs in that when the sliding size is larger than the size of the list then an empty list is returned, rather than a partial entry.
TODO