gapt.utils.streams.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gapt_3 Show documentation
Show all versions of gapt_3 Show documentation
General Architecture for Proof Theory
The newest version!
/*
* streams.scala
*
* Some utility functions for Scala streams.
*/
package gapt.utils
object StreamUtils {
def even[A](s: LazyList[A]): LazyList[A] = if (s.isEmpty) LazyList.empty
else
LazyList.cons(s.head, even(s.tail.tail))
def odd[A](s: LazyList[A]): LazyList[A] = if (s.isEmpty) LazyList.empty
else if (s.tail.isEmpty) LazyList.empty
else LazyList.cons(s.tail.head, odd(s.tail.tail))
}