Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. interface LazySequence<T> {
  2. value: T;
  3. next(): LazySequence<T>;
  4. }
  5.  
  6. // Implement the function:
  7. function initSequence<T>(transform: (value: T) => T): (initialValue: T) => LazySequence<T> {
  8. function _next(v:T): LazySequence<T> {
  9. return {
  10. value: v,
  11. next: () => _next(transform(v))
  12. }
  13. }
  14. return initialValue => _next(initialValue)
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement