Re: Decrease number of front evaluations

2015-08-26 Thread Ali Çehreli via Digitalmars-d-learn
On 08/26/2015 01:27 AM, FreeSlave wrote: > I would want to avoid redundant front evaluations. Another option is std.functional.memoize: import std.stdio; import std.functional; import std.algorithm; import std.array; void main() { auto r = [ 1, 2, 1 ] .map!(memoize!(delegate(i

Re: Decrease number of front evaluations

2015-08-26 Thread Yazan D via Digitalmars-d-learn
On Wed, 26 Aug 2015 08:27:05 +, FreeSlave wrote: > > Are there ways to fix this? Should I consider writing my own range type > probably? Check http://dlang.org/phobos/std_algorithm_iteration.html#.cache

Re: Decrease number of front evaluations

2015-08-26 Thread FreeSlave via Digitalmars-d-learn
On Wednesday, 26 August 2015 at 08:30:04 UTC, Yazan D wrote: On Wed, 26 Aug 2015 08:27:05 +, FreeSlave wrote: Are there ways to fix this? Should I consider writing my own range type probably? Check http://dlang.org/phobos/std_algorithm_iteration.html#.cache I tried it. It can help wit

Decrease number of front evaluations

2015-08-26 Thread FreeSlave via Digitalmars-d-learn
Example: import std.stdio; import std.algorithm; import std.path; import std.file; import std.exception; import std.getopt; import std.array; import std.range; auto algo(string fileName, string[] dirs, string[] extensions) { return dirs.filter!(delegate(dir) { bool ok; collec