September 11

Hi All,

May i know whether there is any module similar to the Linux command "comm" (finding difference between 2 files), if present can you please guide me through link to the page nor do let me know if there is any other solution.

Eg
File1
list1
list2
list3
lsit5

File2
list1
list3
lsit6

File1 : difference: list6
File2 : difference: list2,list5

From,
Vino

September 11

On Saturday, 11 September 2021 at 23:17:31 UTC, Vino wrote:

>

Hi All,

May i know whether there is any module similar to the Linux command "comm" (finding difference between 2 files), if present can you please guide me through link to the page nor do let me know if there is any other solution.

Eg
File1
list1
list2
list3
lsit5

File2
list1
list3
lsit6

File1 : difference: list6
File2 : difference: list2,list5

From,
Vino

Take a look at https://dlang.org/phobos/std_algorithm_setops.html

With these inputs:

import std.string : strip, splitLines;
import std.algorithm : equal, setDifference;

string[] File1 = q"EOF
list1
list2
list3
list5
EOF".strip.splitLines;

string[] File2 = q"EOF
list1
list3
list6
EOF".strip.splitLines;

unittest {
    assert(["list2", "list5"].equal(File1.setDifference(File2)));
    assert(["list6"].equal(File2.setDifference(File1)));
}