PatOps
PatOps
are operations for patterns (Pat
). Instead of having these operations directly defined
in each pattern, which is a huge list, they appear here as extension methods.
- See also
Pat
Value members
Concrete methods
"Taps" into this pattern by appending a side-effect. The returned
pattern will invoke both the input stream and the stream
produced from the side-effecting pattern produced by f
,
and then pass through the input stream's value.
The side-effecting stream may end early, the compound stream keeps
producing while the input stream has elements.
"Taps" into this pattern by appending a side-effect. The returned
pattern will invoke both the input stream and the stream
produced from the side-effecting pattern produced by f
,
and then pass through the input stream's value.
The side-effecting stream may end early, the compound stream keeps
producing while the input stream has elements.
Similar to runWith
for standard Scala collections.
Wraps each element in a singleton pattern. For example,
Pat(1, 2, 3)
becomes Pat(Pat(1), Pat(2), Pat(3))
.
Wraps each element in a singleton pattern. For example,
Pat(1, 2, 3)
becomes Pat(Pat(1), Pat(2), Pat(3))
.
Chooses a random single element from the input pattern.
Chooses a random single element from the input pattern.
Drops the first length
elements of the input pattern.
If the length is greater than the input pattern length, the
result will be empty.
Drops the first length
elements of the input pattern.
If the length is greater than the input pattern length, the
result will be empty.
E.g. Pat(4, 5, 6).drop(2) == Pat(6)
Finds first index where this pattern contains a given other pattern as a slice.
Finds first index where this pattern contains a given other pattern as a slice.
- Value Params
- that
the sequence to test
- Returns
the first index such that the elements of this pattern starting at this index match the elements of pattern
that
, or-1
of no such subsequence exists.
Finds first index after or at a start index where this pattern contains a given other pattern as a slice.
Finds first index after or at a start index where this pattern contains a given other pattern as a slice.
- Value Params
- from
the start index
- that
the sequence to test
- Returns
the first index
>= from
such that the elements of this pattern starting at this index match the elements of patternthat
, or-1
of no such subsequence exists.
Yields the number of elements in the input pattern.
Yields the number of elements in the input pattern.
E.g. Pat(4, 5, 6).length == Pat(3)
Randomly changes the positions of the elements in the input pattern. Warning: the input must be finite.
Randomly changes the positions of the elements in the input pattern. Warning: the input must be finite.
Drops the first element of the pattern.
Drops the first element of the pattern.
E.g. Pat(4, 5, 6).tail == Pat(5, 6)
.
Takes only the length
first elements of the input pattern,
or less if the input pattern is shorter.
Takes only the length
first elements of the input pattern,
or less if the input pattern is shorter.
E.g. Pat(4, 5, 6).take(2) == Pat(4, 5)
Updates a single element. In other words, only one element from
index
and elem
is ever read.
Updates a single element. In other words, only one element from
index
and elem
is ever read.
E.g. Pat(4, 5, 6).updated(2, 7) == Pat(4, 5, 7)