Re: A Recurring Question

2016-04-18 Thread w0rp via Digitalmars-d
On Monday, 18 April 2016 at 20:24:40 UTC, Jesse Phillips wrote: On Sunday, 17 April 2016 at 15:23:50 UTC, w0rp wrote: void main() { // Print all directories from this one up to and including /. getcwd() .unaryRecurrence!dirName .until("/", OpenRight.no) .each!writeln; } F

Re: A Recurring Question

2016-04-18 Thread w0rp via Digitalmars-d
On Monday, 18 April 2016 at 12:02:24 UTC, thedeemon wrote: On Sunday, 17 April 2016 at 15:23:50 UTC, w0rp wrote: auto unaryRecurrence(alias func, T)(T initialValue) { return recurrence!((values, index) => func(values[0]))(initialValue); } This is kind of neat. My question is, should som

Re: A Recurring Question

2016-04-18 Thread Jesse Phillips via Digitalmars-d
On Sunday, 17 April 2016 at 15:23:50 UTC, w0rp wrote: void main() { // Print all directories from this one up to and including /. getcwd() .unaryRecurrence!dirName .until("/", OpenRight.no) .each!writeln; } FYI, OS independent version: void main() { // Print all direc

Re: A Recurring Question

2016-04-18 Thread thedeemon via Digitalmars-d
On Sunday, 17 April 2016 at 15:23:50 UTC, w0rp wrote: auto unaryRecurrence(alias func, T)(T initialValue) { return recurrence!((values, index) => func(values[0]))(initialValue); } This is kind of neat. My question is, should something like this function be included in std.range? Either

A Recurring Question

2016-04-17 Thread w0rp via Digitalmars-d
I recently found myself wanting an algorithm to apply f(x) repeatedly, generating an infinite sequence, for a variety of reasons. One of those reasons is to generate ancestor directories. Typically when I desire such a thing, I find myself trying to find the existing algorithm which does this a