diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-12-01 17:44:35 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-12-01 17:44:35 -0800 |
commit | a83be33140ca28317d0b6c733174ad344f6a2de0 (patch) | |
tree | 20f504b0386cba65100901f2e92a027059601741 | |
parent | 4f54c242eb83ab5bab39d6e83b074fbe0a88feee (diff) | |
parent | c23a1eaa6cf0b9632b38606eab9f08b796cd0182 (diff) | |
download | scala-a83be33140ca28317d0b6c733174ad344f6a2de0.tar.gz scala-a83be33140ca28317d0b6c733174ad344f6a2de0.tar.bz2 scala-a83be33140ca28317d0b6c733174ad344f6a2de0.zip |
Merge pull request #4143 from Ichoran/issue/8695
SI-8695 SeqLike has unintuitive implementation of combinations
-rw-r--r-- | src/library/scala/collection/SeqLike.scala | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index fdfb1f2efc..329273df5b 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -140,7 +140,15 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ if (isEmpty) Iterator(repr) else new PermutationsItr - /** Iterates over combinations. + /** Iterates over combinations. A _combination_ of length `n` is a subsequence of + * the original sequence, with the elements taken in order. Thus, `"xy"` and `"yy"` + * are both length-2 combinations of `"xyy"`, but `"yx"` is not. If there is + * more than one way to generate the same subsequence, only one will be returned. + * + * For example, `"xyyy"` has three different ways to generate `"xy"` depending on + * whether the first, second, or third `"y"` is selected. However, since all are + * identical, only one will be chosen. Which of the three will be taken is an + * implementation detail that is not defined. * * @return An Iterator which traverses the possible n-element combinations of this $coll. * @example `"abbbc".combinations(2) = Iterator(ab, ac, bb, bc)` |