Array reduction operator question

In reply to rag123:


I am expecting the result queue to be populated with the number equal to the one present both in arr and q. The below equation i have doesnt give expected result.
module top();
int q[$];
int result[$];
int arr[$];
initial begin
arr = {9,1,8};
q = {9, 1, 8, 3, 4, 4};
$display("1. queue 'q' in decimal : %p", q);
result =  q.find(i) with (i == arr[i]);
$display("1. find with i inside arr[i] : %p",result  );
end
endmodule : top
Expected result[$] = 9,1,8;

I think you just need to use

result =  q.find(i) with (i == arr[i.index]});

Regarding your code ask yourself this, what would be the value when i=9, of are[9]?
HTH,
-R