'scala seq.combinations returns out of order results

scala docs say that combinations method should do the following

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

https://www.scala-lang.org/api/2.13.3/scala/collection/immutable/List.html

but running

"aba".combinations(3).toList // return List("aab")

this is obviously out of order, it is expected to return List("aba"). As a side note, this is how it works in other languages, like python itertools.combinations, where we get List("aba") as expected. Am I misunderstanding how this should work, or is it a bug?

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



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source