SeqDecorator
Attributes
- C
type of the decorated collection (e.g.
List[Int]
,String
, etc.)- coll
the decorated collection
- seq
evidence that type
C
is a sequence- Graph
- Supertypes
- class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
Adds the element sep
between each element of the sequence.
If the sequence has less than two elements, the collection is unchanged.
Adds the element sep
between each element of the sequence.
If the sequence has less than two elements, the collection is unchanged.
Attributes
- B
the element type of the returned collection
- sep
the element to intersperse
- Returns:
a new collection consisting of all elements of this collection interspersed with the element
sep
- Example:
List(1, 2, 3, 4).intersperse(0) = List(1, 0, 2, 0, 3, 0, 4)
Adds the element sep
between each element of the sequence,
prepending start
and appending end
.
If the sequence has less than two elements, returns start +: this :+ end
.
Adds the element sep
between each element of the sequence,
prepending start
and appending end
.
If the sequence has less than two elements, returns start +: this :+ end
.
Attributes
- B
the element type of the returned collection
- end
the element to append
- sep
the element to intersperse
- start
the element to prepend
- Returns:
a new collection consisting of all elements of this collection interspersed with the element
sep
, beginning withstart
and ending withend
- Example:
List(1, 2, 3, 4).intersperse(-1, 0, 5) => List(-1, 1, 0, 2, 0, 3, 0, 4, 5)
Produces a new sequence where all occurrences of some element are replaced by a different element.
Produces a new sequence where all occurrences of some element are replaced by a different element.
Attributes
- B
the element type of the returned collection.
- elem
the element to replace
- replacement
the replacement element
- Returns:
a new sequence consisting of all elements of this sequence except that all occurrences of
elem
are replaced byreplacement