summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/SeqLike.scala
diff options
context:
space:
mode:
authorRex Kerr <ichoran@gmail.com>2014-11-21 12:52:36 -0800
committerRex Kerr <ichoran@gmail.com>2014-11-23 12:59:31 -0800
commitc23a1eaa6cf0b9632b38606eab9f08b796cd0182 (patch)
treee57269962445f6c98b088cd3d0cc2829016175d5 /src/library/scala/collection/SeqLike.scala
parentc4df20d29a8d15ef23cf0d10fad56da0791bbbf6 (diff)
downloadscala-c23a1eaa6cf0b9632b38606eab9f08b796cd0182.tar.gz
scala-c23a1eaa6cf0b9632b38606eab9f08b796cd0182.tar.bz2
scala-c23a1eaa6cf0b9632b38606eab9f08b796cd0182.zip
SI-8695 SeqLike has unintuitive implementation of combinations
Clarified what `combinations` means in the docs.
Diffstat (limited to 'src/library/scala/collection/SeqLike.scala')
-rw-r--r--src/library/scala/collection/SeqLike.scala10
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)`