This repository contains an own implementation of a Stream inspired by Functional Programming in Scala. It provides an implementation for
constant: Create a infinite stream with given integerfrom: Create an infinite stream counting from the given integerfrom: Create a stream from given listempty: Empty streamfilter: Filter a stream for elements which yield true for a given predicatefoldRight: Reduce the stream to one value with given aggregateBiFunctionand neutral elementz.unfold: Unfold stream from initial state and a next state function.primes: Infinite stream of prime numbersrangeClosed: Range fromstarttoend(inclusive)noneMatch: True if none of the elements in a stream fullfills the predicateanyMatch: True if at least one element in a stream fullfills the predicateallMatch: True if all elements in a stream fullfill the predicatelimit: limits the amount of elements in the streammap: apply given function to each element of the stream
Primes generation can also be done with Java 8s Stream implementation (look into test source package).
// Following code constructs a stream of one element
Stream<String> one = Stream.cons(() -> "Just one", () -> Stream.empty());
// Filter stream
Stream<String> one = Stream.cons(() -> "one", () -> Stream.cons(() -> "second", () -> Stream.empty())).filter("one"::equals); // Stream with one element
// Constant stream of ones
Stream<Integer> ones = Stream.constant(1);