You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: overviews/collections/seqs.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ The [Seq](http://www.scala-lang.org/api/current/scala/collection/Seq.html) trait
13
13
14
14
The operations on sequences, summarized in the table below, fall into the following categories:
15
15
16
-
***Indexing and length** operations `apply`, `isDefinedAt`, `length`, `indices`, and `lengthCompare`. For a `Seq`, the `apply` operation means indexing; hence a sequence of type `Seq[T]` is a partial function that takes an `Int` argument (an index) and which yields a sequence element of type `T`. In other words `Seq[T]` extends `PartialFunction[Int, T]`. The elements of a sequence are indexed from zero up to the `length` of the sequence minus one. The `length` method on sequences is an alias of the `size` method of general collections. The `lengthCompare` method allows you to compare the lengths of two sequences even if one of the sequences has infinite length.
16
+
***Indexing and length** operations `apply`, `isDefinedAt`, `length`, `indices`, and `lengthCompare`. For a `Seq`, the `apply` operation means indexing; hence a sequence of type `Seq[T]` is a partial function that takes an `Int` argument (an index) and which yields a sequence element of type `T`. In other words `Seq[T]` extends `PartialFunction[Int, T]`. The elements of a sequence are indexed from zero up to the `length` of the sequence minus one. The `length` method on sequences is an alias of the `size` method of general collections. The `lengthCompare` method allows you to compare the lengths of a sequences with an Int even if the sequences has infinite length.
17
17
***Index search operations**`indexOf`, `lastIndexOf`, `indexOfSlice`, `lastIndexOfSlice`, `indexWhere`, `lastIndexWhere`, `segmentLength`, `prefixLength`, which return the index of an element equal to a given value or matching some predicate.
18
18
***Addition operations**`+:`, `:+`, `padTo`, which return new sequences obtained by adding elements at the front or the end of a sequence.
19
19
***Update operations**`updated`, `patch`, which return a new sequence obtained by replacing some elements of the original sequence.
@@ -32,7 +32,7 @@ If a sequence is mutable, it offers in addition a side-effecting `update` method
32
32
|`xs(i)`|(or, written out, `xs apply i`). The element of `xs` at index `i`.|
33
33
|`xs isDefinedAt i`|Tests whether `i` is contained in `xs.indices`.|
34
34
|`xs.length`|The length of the sequence (same as `size`).|
35
-
|`xs.lengthCompare ys`|Returns `-1` if `xs` is shorter than `ys`, `+1` if it is longer, and `0`is they have the same length. Works even if one if the sequences is infinite.|
35
+
|`xslengthCompare n`|Returns `-1` if `xs` is shorter than `n`, `+1` if it is longer, and `0`if it is of length`n`. Works even if the sequence is infinite, for example `Stream.from(1) lengthCompare 42` equals `+1`.|
36
36
|`xs.indices`|The index range of `xs`, extending from `0` to `xs.length - 1`.|
37
37
|**Index Search:**||
38
38
|`xs indexOf x`|The index of the first element in `xs` equal to `x` (several variants exist).|
0 commit comments