Skip to content

Combinations doesn't handle duplicate elements #12540

Closed
scala/scala
#9947
@arminsumo

Description

@arminsumo

reproduction steps

using Scala 2.13,

"aba".combinations(3).toSeq // returns Seq("aab"), should return Seq("aba")
"abaa".combinations(3).toSeq // returns Seq("aaa", "aab"), should return Seq("aaa", "aba")

https://scastie.scala-lang.org/V3sDnjcJTTSjVq3nfKXLzA

problem

Combinations method does not seem to gracefully handle input with duplicated elements. The output does not represent an ordered combination of the input, as the docs suggest it should do

Iterates over combinations. A _combination_ of length n is a subsequence of the original sequence, with the elements taken in order.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions