{"action":"created","issue":{"url":"https://api.github.com/repos/javaslang/javaslang/issues/1775","repository_url":"https://api.github.com/repos/javaslang/javaslang","labels_url":"https://api.github.com/repos/javaslang/javaslang/issues/1775/labels{/name}","comments_url":"https://api.github.com/repos/javaslang/javaslang/issues/1775/comments","events_url":"https://api.github.com/repos/javaslang/javaslang/issues/1775/events","html_url":"https://github.com/javaslang/javaslang/issues/1775","id":197864520,"number":1775,"title":"Implement Traversable.slideBy(classifier)","user":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"labels":[{"id":204492036,"url":"https://api.github.com/repos/javaslang/javaslang/labels/feature","name":"feature","color":"009800","default":false},{"id":480739450,"url":"https://api.github.com/repos/javaslang/javaslang/labels/%C2%ABcollections%C2%BB","name":"«collections»","color":"f7f7f7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/javaslang/javaslang/milestones/20","html_url":"https://github.com/javaslang/javaslang/milestone/20","labels_url":"https://api.github.com/repos/javaslang/javaslang/milestones/20/labels","id":1294243,"number":20,"title":"2.1.0","description":"Boost up collection performance","creator":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"open_issues":70,"closed_issues":448,"state":"open","created_at":"2015-09-07T18:46:28Z","updated_at":"2016-12-31T16:06:31Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2016-12-28T14:48:40Z","updated_at":"2017-01-01T16:59:17Z","closed_at":null,"body":"**Example:**\r\n\r\n```java\r\n// Vector(List(a1, a2), List(b1), List(a3))\r\nList(\"a1\", \"a2\", \"b1\", \"a3\").slideBy(s -> s.substring(0, 1))\r\n```\r\n\r\nSee also [Scala List function for grouping consecutive identical elements](http://stackoverflow.com/questions/4761386/scala-list-function-for-grouping-consecutive-identical-elements)\r\n\r\n---\r\n\r\n**Traversable** has\r\n\r\n> _// same as sliding(size, size)_\r\n> [grouped(int size)](http://static.javadoc.io/io.javaslang/javaslang/2.1.0-alpha/javaslang/collection/Traversable.html#grouped-int-) &rightarrow; Iterator&lt;? extends Traversable&lt;T&gt;&gt;\r\n> [groupBy(Function&lt;? super T,? extends C&gt; classifier)](http://static.javadoc.io/io.javaslang/javaslang/2.1.0-alpha/javaslang/collection/Traversable.html#groupBy-java.util.function.Function-) &rightarrow; Map&lt;C,? extends Traversable&lt;T&gt;&gt;\r\n\r\n> _// same as sliding(size, 1)_\r\n> [sliding(int size)](http://static.javadoc.io/io.javaslang/javaslang/2.1.0-alpha/javaslang/collection/Traversable.html#sliding-int-) &rightarrow; Iterator&lt;? extends Traversable&lt;T&gt;&gt;\r\n> [sliding(int size, int step)](http://static.javadoc.io/io.javaslang/javaslang/2.1.0-alpha/javaslang/collection/Traversable.html#sliding-int-int-) &rightarrow; Iterator&lt;? extends Traversable&lt;T&gt;&gt;\r\n\r\nThe new function will be also part of Traversable, namely:\r\n\r\n> **slideBy(Function&lt;? super T,? extends C&gt; classifier) &rightarrow; Seq&lt;? extends Traversable&lt;T&gt;&gt;**\r\n\r\nThoughts on the implementation:\r\n\r\n* The returned Seq is a Vector (internally), as part of our strategy to make Vector the default Seq\r\n* We should also implement it as part of Collections (see Collections.groupBy).\r\n* There will be no default implementation. The methods need to be overridden throughout the collection hierarchy (see Traversable.groupBy()), i.e.\r\n\r\n> Traversable.slideBy(classifier) &rightarrow; Seq&lt;? extends Traversable&gt;\r\n> Seq.slideBy(classifier) &rightarrow; Seq&lt;? extends Seq&gt;\r\n> LinearSeq.slideBy(classifier) &rightarrow; Seq&lt;? extends LinearSeq&gt;\r\n> List.slideBy(classifier) &rightarrow; Seq&lt;List&gt;\r\n\r\nPlease note that the 'terminal' types (like List, not necessarily a final class) do not specify bounded generics as part of the return type."},"comment":{"url":"https://api.github.com/repos/javaslang/javaslang/issues/comments/269910439","html_url":"https://github.com/javaslang/javaslang/issues/1775#issuecomment-269910439","issue_url":"https://api.github.com/repos/javaslang/javaslang/issues/1775","id":269910439,"user":{"login":"jest","id":161816,"avatar_url":"https://avatars.githubusercontent.com/u/161816?v=3","gravatar_id":"","url":"https://api.github.com/users/jest","html_url":"https://github.com/jest","followers_url":"https://api.github.com/users/jest/followers","following_url":"https://api.github.com/users/jest/following{/other_user}","gists_url":"https://api.github.com/users/jest/gists{/gist_id}","starred_url":"https://api.github.com/users/jest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jest/subscriptions","organizations_url":"https://api.github.com/users/jest/orgs","repos_url":"https://api.github.com/users/jest/repos","events_url":"https://api.github.com/users/jest/events{/privacy}","received_events_url":"https://api.github.com/users/jest/received_events","type":"User","site_admin":false},"created_at":"2017-01-01T16:59:17Z","updated_at":"2017-01-01T16:59:17Z","body":"Man, that is a whole lot of file editing for such a small feature. :-) Anyway, first result is in https://github.com/jest/javaslang/tree/slideby-feature. Initially naively copying `Iterator.sliding()` with small tweaks, and no tests."}}
{"actor":{"display_login":"jest"}}