import { type List, type Pair } from './list'; type NonEmptyStream = Pair Stream>; export type Stream = null | NonEmptyStream; /** * Makes a Stream out of its arguments\ * LOW-LEVEL FUNCTION, NOT SOURCE */ export declare function stream(): null; export declare function stream(...elements: T[]): NonEmptyStream; export declare function list_to_stream(xs: List): Stream; export declare function stream_tail(stream: NonEmptyStream): Stream; /** * Returns `true` is the given object is a stream. * * NOT Lazy: The function must evaluate all the elements of the stream */ export declare function is_stream(obj: unknown): obj is Stream; /** * Constructs an infinite stream of integers, beginning with n, incrementing 1 at * a time. * * Lazy. */ export declare function integers_from(n: number): Stream; /** * Builds a stream of n elements by applying the provided function to the * numbers [0, n-1]. * * Lazy: f is only called when the resulting stream is forced. */ export declare function build_stream(f: (n: number) => T, n: number): Stream; /** * Applies the provided function to elements of the given stream. * * Lazy: the provided function does not execute until the * forced by the resulting stream. */ export declare function stream_map(f: (arg: T) => U, s: Stream): Stream; /** * Returns a substream containing the elements that the provided predicate returned `true` for. * * Partially Lazy: Both the predicate and stream are evaluated as necessary */ export declare function stream_filter(f: (arg: T) => arg is U, s: Stream): Stream; export declare function stream_filter(f: (arg: T) => boolean, s: Stream): Stream; /** * Applies the given function to every single element of the stream. * * NOT lazy: This function evaluates the entire stream. */ export declare function stream_for_each(f: (arg: T) => void, s: Stream): boolean; /** * Accumulate applies given operation op to elements of a stream * in a right-to-left order, first apply op to the last element * and an initial element, resulting in r1, then to the second-last * element and r1, resulting in r2, etc, and finally to the first element * and r_n-1, where n is the length of the list. `accumulate(op,zero,list(1,2,3))` * results in `op(1, op(2, op(3, zero)))`. * * NOT lazy: This function evaluates the entire stream when called */ export declare function stream_accumulate(f: (each: T, result: U) => U, initial: U, stream: Stream): U; /** * Returns the length of the stream. * * NOT lazy: The function must evaluate the entire stream */ export declare function stream_length(s: Stream): number; /** * Returns the nth element of the stream. * * NOT lazy: The stream must be evaluated up to the nth element. */ export declare function stream_ref(s: Stream, n: number): T; /** * Appends a stream to the end of another stream. * * @param lhs Stream to append to * @param rhs Stream to be appending * * Lazy: `rhs` is only evaluated after `lhs` is fully evaluated. This * does mean that if `lhs` is infinite elements from `rhs` will never be evaluated. */ export declare function stream_append(lhs: Stream, rhs: Stream): Stream; /** * Converts the given stream to a {@link List|list}. * * NOT Lazy: Function has to evaluate every element of the stream * to populate the resulting list */ export declare function stream_to_list(stream: Stream): List; export {};