Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface LazySequence<T> {
- value: T;
- next(): LazySequence<T>;
- }
- // Implement the function:
- function initSequence<T>(transform: (value: T) => T): (initialValue: T) => LazySequence<T> {
- function _next(v:T): LazySequence<T> {
- return {
- value: v,
- next: () => _next(transform(v))
- }
- }
- return initialValue => _next(initialValue)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement