diff options
Diffstat (limited to 'src/utils/StreamUtils.scala')
-rw-r--r-- | src/utils/StreamUtils.scala | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/utils/StreamUtils.scala b/src/utils/StreamUtils.scala index 4f803c0..be5246c 100644 --- a/src/utils/StreamUtils.scala +++ b/src/utils/StreamUtils.scala @@ -17,6 +17,11 @@ object StreamUtils { def continuous[A](xs: Seq[A]): Stream[A] = xs.to[Stream] append continuous(xs.to[Stream]) + def pairsOf[A](xs: Seq[A]): Seq[(A, A)] = + (xs.init zip xs.tail.tails.toSeq) flatMap { case (elem, rest) => + rest zip Stream.continually(elem) + } + /* // Or just xs.to[Stream] ... def fromSeq[A](xs: Seq[A]): Stream[A] = |