Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

vino.B bheeman.vino at hotmail.com
Tue Jul 10 14:58:42 UTC 2018


On Tuesday, 10 July 2018 at 14:50:53 UTC, Alex wrote:
> On Tuesday, 10 July 2018 at 14:38:03 UTC, vino.B wrote:
>> Hi Alex,
>>
>>   The reason the I am storing the output of "PFresult.toRange" 
>> to another array "rData" is that the output of the  
>> PFresult.toRange is different each time we execute the 
>> code.(Data is correct) but the way the it output is different. 
>> Is there any way to get the result in a single array - Whole 
>> Data.
>>
>> Single array - Whole Data
>> ["C:\\Temp\\TEAM1\\Test Result-Team1.docx", 2018-Jun-28 
>> 17:37:45.9376229,
>> "C:\\Temp\\TEAM2\\Test Result-Team2.docx", 2018-Jun-28 
>> 17:37:45.9376229,
>> "C:\\Temp\\SAPNAS3\\TEAM3\\Test Result-Team3.docx", 
>> 2018-Jun-28 17:37:45.9376229
>> ]
>>
>> One array - For Each Data
>> [ C:\\Temp\\TEAM1\\Test Result-Team1.docx", 2018-Jun-28 
>> 17:37:45.9376229] - arr1
>> [ C:\\Temp\\TEAM2\\Test Result-Team2.docx", 2018-Jun-28 
>> 17:37:45.9376229] - arr2
>> [ C:\\Temp\\TEAM3\\Test Result-Team3.docx", 2018-Jun-28 
>> 17:37:45.9376229] - arr3
>>
>> The code in the program.
>>
>>  foreach(i; PFresult.toRange) { rData ~= i[][]; }
>>  if (!rData[].empty) { rData[].sort!((a,b) => a[1] < 
>> b[1]).each!(e => logF.writefln!"%-83s 
>> %.20s"(e[0].replace(`\\?\`, ""), e[1].to!string)); }
>>
>> From,
>> Vino.B
>
> Not sure, if I get your point, but are you aware of tuples?
> https://dlang.org/phobos/std_typecons.html#tuple

Hi Alex,

  I am getting the output as tuples of multiple arrays, but the 
requirement is to get the all the tuple in a single array like 
the below so that we can perform sorting and printing the output 
is easy.


[
"C:\\Temp\\TEAM1\\Test Result-Team1.docx", 2018-Jun-28 
17:37:45.9376229,
"C:\\Temp\\TEAM2\\Test Result-Team2.docx", 2018-Jun-28 
17:37:45.9376229,
"C:\\Temp\\SAPNAS3\\TEAM3\\Test Result-Team3.docx", 2018-Jun-28 
17:37:45.9376229
]


if (!rData[].empty)
{
  rData[].sort!((a,b) => a[1] < b[1]).each!(e => 
logF.writefln!"%-83s %.20s"(e[0],
  e[1].to!string));
}

From,
Vino.B


More information about the Digitalmars-d-learn mailing list