Container Array

Vino.B via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 7 03:56:59 PDT 2017


On Wednesday, 6 September 2017 at 16:41:06 UTC, Vino.B wrote:
> HI All,
>
>  Can some one provide me a example of how to use the 
> std.container.array for the below code.
>
> import std.algorithm: filter, map;
> import std.file: SpanMode, dirEntries, isDir;
> import std.stdio: writeln;
> import std.typecons: tuple;
> import std.array: array;
>
> void main () {
> 	string[] Filesys = ["C:\\Temp\\TEST1\\BACKUP", 
> "C:\\Temp\\TEST2\\EXPORT"];
> 	foreach(FFs; Filesys) {
> 		auto dFiles = dirEntries("C:\\Temp\\TEST1\\BACKUP", 
> SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name, 
> a.size));
> 		foreach(d; dFiles)
> 		writeln(d[0], "\t", d[1]);
> 		}
> }
>
> From,
> Vino.B

Hi,

   I tried a small code using container array, and the output i 
get form the code is a below, so can one help me on this issue.

Program:
import std.algorithm: filter, map;
import std.file: SpanMode, dirEntries, isDir;
import std.stdio: writeln;
import std.typecons: tuple, Tuple;
import std.container;

Array!(Tuple!(string, string)) coCleanFiles() {
	auto dFiles = make!Array(dirEntries("C:\\Temp\\TEST1\\BACKUP", 
SpanMode.shallow).filter!(a => a.isFile).map!(a => tuple(a.name, 
a.timeCreated.toSimpleString[0 .. 20])));
	return dFiles;
}

void main () {
writeln(coCleanFiles);
}

Output:
Array!(Tuple!(string, string))(RefCounted!(Payload, 
cast(RefCountedAutoInitialize)0)(RefCountedStore(62D818)))

From,
Vino.B



More information about the Digitalmars-d-learn mailing list