Missing array element

Vino.B via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 29 11:20:38 PDT 2017


Hi,

  Can any one help me on the below program, as I need the missing 
element for array "a" to be printed when compared with array "b"

Program:

import std.stdio, std.array, std.algorithm;
string[] a = ["test1", "test2", "test4"];
string[] b = ["test2", "test4"];
void main ()
{
auto m = mismatch(a,b);
writeln(m[0]);
writeln(m[1]);
}

Output:
["test1", "test2", "test4"]
["test2", "test4"]

Required output: "test1"

From,
Vino.B


More information about the Digitalmars-d-learn mailing list