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
0answers
11 views

Lazy WebAPI object

I am working to design an object which would abstract away the use of a WebAPI. I want the developer to be able to use these objects as if they are using a traditional API. My core problem is how to ...
10
votes
1answer
93 views

Caching data by using the result of first running operation

My code handles concurrent requests by waiting for the result of an already running operation. Requests for data may come in simultaneously with same/different credentials (including empty ...
10
votes
2answers
71 views

Poor man's lazy evaluation in Java 8

I have an class that cheaply imitates a lazy evaluation scheme. The class is for representing a file and additionally providing meta data on the file. Some of the meta-data can be expensive to ...
4
votes
3answers
121 views

Unity Lazy Resolve Implementation

I have been using Microsoft.Unity as my container and have decided that the approach for a lazy implementation causes too much rework. Each time you decide to swap ...
5
votes
2answers
76 views

Reading lines from a file in random order

I originally wrote this as an answer to a question on Stack Overflow, but it turned out so nicely that I decided to post it here to see if I can make it even better. ...
4
votes
1answer
51 views

Clojure word count

I'm fairly new to Clojure and looking to improve my use of the proper idioms, and make my code more readable. Here's the problem: Read from standard input and produce the count of each word to ...
1
vote
1answer
65 views

Early-termination foldLeft for Scala Streams

The foldRight and foldLeft methods for Scala Streams cannot terminate early, so here is my ...
2
votes
2answers
102 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
250 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
487 views

Flatten a tree to a collection of nodes

I have implemented simple tree class as follows: ...
1
vote
2answers
57 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
284 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
71 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
116 views

Converting an array-returning function to a lazy evaluator

Take a look at the following function: ...
4
votes
1answer
205 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
148 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
675 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
370 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
497 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
120 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
202 views

Recursive flatten with lazy evaluation iterator

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

Lazy loaded property readability

I currently have code that looks like this ...
1
vote
1answer
800 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
222 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
877 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
246 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. ...