What is the proper way to find the unique values of an array and store them in another array? When I try:

import std.stdio: writeln;
import std.conv;
import std.algorithm;

void main() {
    int[] unsortedArray = [5, 3, 8, 5, 2, 3, 0, 8];
    int[] uniqueArray;

    uniqueArray = uniq(sort(unsortedArray));
}

I get the compilation error:
sortSetUnique2.d(9): Error: cannot implicitly convert expression uniq(sort(unsortedArray)) of type UniqResult!(binaryFun, SortedRange!(int[], "a < b")) to int[]

which leads me to believe that the output of `uniq` is not necessarily another integer array.

Thanks

Reply via email to