www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Range tee()?

reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
Does Phobos have a way to "tee" a range?

For example, suppose you had something like this:

-------------------------------------------------
// Do something with each file in a dir
dirEntries(selectedDir, SpanMode.shallow)
     .filter!someFilterCriteria
     .doSomethingWithFile;
-------------------------------------------------

It would be really nice to be able to "wiretap" that, to trace/debug/etc 
by nothing more than ADDING a single statement at any desired wiretap point:

-------------------------------------------------
// Do something with each file in a dir
dirEntries(selectedDir, SpanMode.shallow)
     //.tee(a => writeln("FOUND: ", a))  // DEBUG: TRACE ALL FILES FOUND!
     .filter!someFilterCriteria
     //.tee(a => writeln("SELECTED: ", a))  // DEBUG: TRACE RESULT OF 
FILTER!
     .doSomethingWithFile;
-------------------------------------------------

Does something like this already exist Phobos? I tried looking for a 
"tee" in st.algorithm but came up nothing. If not, it seems like a 
pretty glaring omission.
Oct 16
next sibling parent reply lobo <swamplobo gmail.com> writes:
On Monday, 16 October 2017 at 07:28:03 UTC, Nick Sabalausky 
(Abscissa) wrote:
 Does Phobos have a way to "tee" a range?

 For example, suppose you had something like this:

 [...]
https://dlang.org/phobos/std_range.html#tee ?
Oct 16
parent "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 10/16/2017 03:30 AM, lobo wrote:
 On Monday, 16 October 2017 at 07:28:03 UTC, Nick Sabalausky (Abscissa) 
 wrote:
 Does Phobos have a way to "tee" a range?

 For example, suppose you had something like this:

 [...]
https://dlang.org/phobos/std_range.html#tee ?
Ahh, thanks, I was only looking in std.algorithm. Didn't expect it to be in std.range.
Oct 16
prev sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 16 October 2017 at 07:28:03 UTC, Nick Sabalausky 
(Abscissa) wrote:
 Does Phobos have a way to "tee" a range?
use my dpldocs search engine http://dpldocs.info/tee std.range pops right up!
Oct 16