Lazy evaluation refers to a variety of concepts that seek to avoid evaluation of an expression unless its value is needed, and to share the results of evaluation of an expression among all uses of its, so that no expression need be evaluated more than once.

learn more… | top users | synonyms

2
votes
2answers
72 views

Date formatters, lazily instantiated once

I would like to create two date formatters only on first call. In Objective-C I would use dispatch_once() but now working in Swift. Am I doing it correctly? My code ...
2
votes
3answers
166 views

Loading visible images

I am using this code to get images to load only if they are visible. However, it seems to be slow with thousands of images, even if they are not rendered. ...
2
votes
2answers
293 views

Flatten a tree to a collection of nodes

I have implemented simple tree class as follows: ...
1
vote
2answers
47 views

Lazy properties for the angle and length of a line segment

The code below shows the pattern I use to manage properties in my classes when I have the following requirements: Some properties are slow to calculate and are rarely used, so I want them to be lazy ...
10
votes
2answers
218 views

Lazy String.Split

C#'s String.Split method comes from C# 2.0, and lazy operations weren't a feature back then. The task is to split a string according to a (single) separator. Doing ...
3
votes
1answer
61 views

SICP streams in C++

To brush up on my C++ chops, I've implemented a toy version of "SICP Streams", which behave like lists with one twist: the first element of the list is always available, the rest of the list is stored ...
3
votes
1answer
108 views

Converting an array-returning function to a lazy evaluator

Take a look at the following function: ...
4
votes
1answer
151 views

Lazy Load for multiple entities at a time

We have a system with a non standard database solution. All trips to the DB are rather expensive. We cannot use entity framework. Currently our lazy loading is on an entity by entity basis. So if I ...
7
votes
4answers
147 views

Calculating Fibonnaci sequence lazily

Implementation: ...
2
votes
1answer
57 views

Perfect elimination ordering and high memory usage

The following code calculates a perfect elimination ordering in a special case in Haskell. I am less worried about its correctness than its high use of memory. The following code runs out of memory ...
7
votes
3answers
509 views

Lazily Load CSS and JS

I have written this piece of JS and CSS loading code and I would like some advice on it. Anything some of the JavaScript gurus could possibly point out would be much appreciated. The code works, but I ...
2
votes
1answer
253 views

AsyncLazy disposal

I've made this extension method. Its purpose is to trigger the disposal of a value, stored in a Nito.AsyncEx AsyncLazy, as authored by @StephenCleary. Is this an ...
7
votes
2answers
474 views

Generic cached value class mimicking Lazy<T>

Before I wrote this I searched and found a number of solutions that make use of a caching provider to handle a set of items. I felt that was too cumbersome of an approach and set out to create a class ...
3
votes
2answers
115 views

Azure cache getoradd (without locking)

Inspired by the non-locking implementation proposed in this post, the following code is an attempt to (about) do the same using the azure cache. As I'm totally green on the Azure cache I'd appreciate ...
4
votes
2answers
169 views

Recursive flatten with lazy evaluation iterator

I'm trying to rewrite this: ...
11
votes
2answers
2k views

Lazy loaded property readability

I currently have code that looks like this ...
1
vote
1answer
738 views

Lazy loading with __get

I have my own PHP MVC framework that I'm iteratively developing (i.e. adding a feature when I have the time). I'm trying to keep it to the best practices I can, while still adding the most in terms of ...
2
votes
2answers
209 views

Are there any issues in this `Lazy` implementation?

I have written following small utility to abstract away the lazy initialization logic. (I tend to use lazy variables quite often.) Are there any issues in this implementation? ...
2
votes
2answers
799 views

Lazy class instantiation in Python

I've written some class which allows me to derive from it to make objects lazy-instantiated. Do you see notational improvements or maybe even cases where this method might not work (multiple ...
4
votes
1answer
236 views

Lazy look and say sequence

I have been solving a set of online Clojure problems. One of them involves the look and say sequence. ...