mirror of
https://github.com/dlang/phobos.git
synced 2025-04-26 13:10:35 +03:00

* added Lazycache feature * Added Lazycache funtion * changes as per review * Update std/algorithm/iteration.d Co-authored-by: Richard (Rikki) Andrew Cattermole <pbdadmin@gmail.com> * removing unrelated change * added lazychache in cheatsheet * removed error * add_lazycache_function.dd * changes in changelog * lines changes in changelog * removing whitspace --------- Co-authored-by: Richard (Rikki) Andrew Cattermole <pbdadmin@gmail.com>
15 lines
No EOL
560 B
Text
15 lines
No EOL
560 B
Text
Add lazyCache to std.algorithm.iteration
|
|
|
|
The new `lazyCache` function provides a lazily evaluated range caching mechanism.
|
|
Unlike `cache`, which eagerly evaluates range elements during construction,
|
|
`lazyCache` defers evaluation until elements are explicitly requested.
|
|
|
|
---
|
|
auto result = iota(-4, 5).map!(a => tuple(a, expensiveComputation(a)))().lazyCache();
|
|
// No computations performed at this point
|
|
|
|
auto firstElement = result.front;
|
|
// First element is now evaluated
|
|
---
|
|
|
|
See the $(REF lazyCache, std,algorithm,iteration) documentation for more details. |