On 20.12.17 17:30, Christian Köstlin wrote: > thats an idea, thank a lot, will give it a try ... #!/usr/bin/env rdmd -unittest unittest { import std.stdio; import std.range; import std.algorithm; import std.string; import std.functional;
auto parse(int i) { writeln("parsing %s".format(i)); return [1, 2, 3]; } writeln(iota(1, 5).map!(memoize!parse)); writeln("-------------------------------"); writeln((iota(1, 5).map!(memoize!parse)).joiner); } void main() {} works, but i fear for the data that is stored in the memoization. at the moment its not a big issue, as all the data fits comfortable into ram, but for bigger data another approach is needed (probably even my current json parsing must be exchanged). I still wonder, if the joiner calls front more often than necessary. For sure its valid to call front as many times as one sees fit, but with a lazy map in between, it might not be the best solution.