Unique (indices) method similar to MATLAB

You can pass a function to unique in order to get the indices of the unique elements:

idx = unique(z -> x[z], 1:length(x))
x[idx]
7 Likes