Questions tagged [lazy]
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.
74 questions
3
votes
2
answers
161
views
Base16/32/64 implementation for C++ ranges
Introduction
The following code is an implementation of, in ambition, RFC 4648 compliant Base16, Base32 and Base64 conversions as range adaptors and constrained algorithms in C++23. It can be used at ...
2
votes
0
answers
107
views
std::ranges compile time (and run time) RFC 4648 compliant Base16 conversions in C++23 (improved 2)
This increment
This obsoletes a former version, after taking a great review into account:
The encoding now preserves sized_range and ...
3
votes
1
answer
207
views
Compile time (and run time) RFC 4648 compliant Base16 conversions as range adaptors in C++23 (improved) [duplicate]
Edit: obsoleted by an improved version.
Edit: now updated with unit tests that show that this implementation also works for non-forward ranges, i.e. string streams, files streams, on-the-fly encoding/...
4
votes
2
answers
383
views
Compile time (and run time) RFC 4648 compliant Base16 conversions as range adaptors in C++23
This obsoletes a former version and is obsoleted by an improved version.
The following code is an implementation of, in ambition, RFC 4648 compliant Base16 conversions as range adaptors in C++23. It ...
4
votes
1
answer
236
views
Hexadecimal conversions as range adaptors in C++23 that work at compile time (and run time) [duplicate]
This is obsoleted by a significantly better version.
The following code is an implementation of hexadecimal conversions as range adaptors in C++23. It can be used at compile time, but should of course ...
3
votes
1
answer
361
views
Implementation of java.util.stream.Stream (and friends) that reads lines from the internet without requiring you to manage the resources
This streams lines of information over the internet using BufferedReader::lines.
However, what makes this special (and thus, extraordinarily complicated imo) is ...
5
votes
1
answer
2k
views
Writing a lazy-evaluation dataclass [closed]
I have a dataclass which is frequently used but is slow because as it processes multiple large datasets. I have tried to speed it up by making it lazily-evaluate, where the data is only read when ...
4
votes
1
answer
287
views
Task manager object for lazy initialization
The Problem
I am developing a Visual Studio extension for importing code from a server.
Because of the way Visual Studio works, multiple threads could try to perform the same operation at the same ...
5
votes
0
answers
218
views
@lazylist - Converts a Python Generator to a List without evaluating every element
Inspired by a blog I read, I made a LazyList class that can wrap an iterable (list, generator etc.) and turn it into a ...
2
votes
2
answers
225
views
How can I make a shorter binary rule in haskell?
Here is a code I experimented with recently:
let br = [0]:[n:(concat $ take n br) | n <- [1..]] in concat br
This code produces the binary rule ...
5
votes
1
answer
439
views
lazy_map implementation in C++ | Similar to unordered_map but O(1) copyable
I implemented lazy_map - https://github.com/tinytrashbin/lazy_map.
Can someone help with reviews ?
lazy_map is an implementation of unordered_map that has O(1) cost
of copying irrespective of the ...
4
votes
1
answer
1k
views
C++ shared pointer wrapper for lazy initialization
I have written a very simple wrapper around std::shared_ptr that supports lazy initialization. Do you see any problems?
...
8
votes
4
answers
643
views
Lazy generator of strings in lexicographical order
I needed to write a Python generator that lazily generates, in lexicographical order, strings composed of a certain alphabet (e.g. lowercase English letters).
My first thought was to make an infinite ...
6
votes
1
answer
421
views
Taking n lines from a file which contains m lines, repeating the file lazily if necessary
The desire for such a function came out of the necessity of generating a "source" of Lorem ipsum by repeating over and over the same 50 or something paragraphs of the text.
Actually I am ...
2
votes
1
answer
257
views
Efficient Implementation of functional and Lazy evaluation in C++
I am creating a c++ library implementing Java Functional Programming alike interface. In short, the code will look like this:
...