LazyList provides lazy evaluation for list operations. Operations are deferred until the list is materialized.
// Basic lazy evaluationconst result = LazyList([1, 2, 3, 4, 5]) .map(x => x * 2) .filter(x => x > 5) .toArray() // [6, 8, 10] Copy
// Basic lazy evaluationconst result = LazyList([1, 2, 3, 4, 5]) .map(x => x * 2) .filter(x => x > 5) .toArray() // [6, 8, 10]
// Infinite sequences with takeconst fibonacci = LazyList.iterate([0, 1], ([a, b]) => [b, a + b]) .map(([a]) => a) .take(10) .toArray() // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] Copy
// Infinite sequences with takeconst fibonacci = LazyList.iterate([0, 1], ([a, b]) => [b, a + b]) .map(([a]) => a) .take(10) .toArray() // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
LazyList provides lazy evaluation for list operations. Operations are deferred until the list is materialized.
Example
Example